{"record":{"id":"0b5b27ffa1e14bf6","repo":"docker/compose","slug":"failed-to-create-resource-w","errorCode":null,"errorMessage":"failed to create resource: %w","messagePattern":"failed to create resource: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/tracing/tracing.go","lineNumber":105,"sourceCode":"\t\t\terrs = append(errs, err)\n\t\t} else if dcExporter != nil {\n\t\t\texporters = append(exporters, dcExporter)\n\t\t}\n\t}\n\tif len(errs) != 0 {\n\t\treturn nil, errors.Join(errs...)\n\t}\n\n\tres, err := resource.New(\n\t\tctx,\n\t\tresource.WithAttributes(\n\t\t\tsemconv.ServiceName(\"compose\"),\n\t\t\tsemconv.ServiceVersion(internal.Version),\n\t\t\tattribute.String(\"docker.context\", dockerCli.CurrentContext()),\n\t\t),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create resource: %w\", err)\n\t}\n\n\tmuxExporter := MuxExporter{exporters: exporters}\n\ttracerProvider := sdktrace.NewTracerProvider(\n\t\tsdktrace.WithResource(res),\n\t\tsdktrace.WithBatcher(muxExporter),\n\t)\n\totel.SetTracerProvider(tracerProvider)\n\n\t// Shutdown will flush any remaining spans and shut down the exporter.\n\treturn tracerProvider.Shutdown, nil\n}\n\n// traceClientFromEnv creates a GRPC OTLP client based on OS environment\n// variables.\n//\n// https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/\nfunc traceClientFromEnv() (otlptrace.Client, envMap) {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/internal/tracing/tracing.go#L87-L123","documentation":"After exporters are assembled, InitProvider builds the OTEL Resource describing the compose service (service.name 'compose', version, docker.context attribute). If resource.New fails, tracing init returns 'failed to create resource: %w'. The resource is built purely from local attributes, so failures are SDK-internal (e.g. attribute validation), not network related.","triggerScenarios":"resource.New(ctx, resource.WithAttributes(...)) erroring — in practice only if an attribute value violates SDK constraints (e.g. an invalid service version string or context name producing an error from the resource detector pipeline); no env or remote calls are involved with these options.","commonSituations":"Very unusual docker context names or build-injected version strings containing characters the OTLP attribute validator rejects; exotic SDK versions with stricter validation; extremely rare in stock builds.","solutions":["Check the wrapped %w for the failing attribute; sanitize the docker context name (docker context rename) or report a compose bug with the value","Retry — transient detector failures are conceivable but this path is deterministic in practice","As a workaround, unset context-based tracing (remove otel from context metadata) and rely on OTEL_* env exporters only","Upgrade compose/OTEL SDK — validation quirks here have been fixed across SDK versions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null // resource construction uses fixed internal attributes","typeGuard":null,"tryCatchPattern":"// degrade gracefully: catch the InitTracing error, log a warning, run without tracing instead of aborting the CLI command","preventionTips":["Use plain (attribute-safe) docker context names (letters, digits, dash, underscore)","Pin a compose version whose OTEL SDK passes validation for your environment"],"tags":["otel","tracing","resource","go"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}