docker/compose · warning
failed to create resource: %w
Error message
failed to create resource: %w
What it means
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.
Source
Thrown at internal/tracing/tracing.go:105
errs = append(errs, err)
} else if dcExporter != nil {
exporters = append(exporters, dcExporter)
}
}
if len(errs) != 0 {
return nil, errors.Join(errs...)
}
res, err := resource.New(
ctx,
resource.WithAttributes(
semconv.ServiceName("compose"),
semconv.ServiceVersion(internal.Version),
attribute.String("docker.context", dockerCli.CurrentContext()),
),
)
if err != nil {
return nil, fmt.Errorf("failed to create resource: %w", err)
}
muxExporter := MuxExporter{exporters: exporters}
tracerProvider := sdktrace.NewTracerProvider(
sdktrace.WithResource(res),
sdktrace.WithBatcher(muxExporter),
)
otel.SetTracerProvider(tracerProvider)
// Shutdown will flush any remaining spans and shut down the exporter.
return tracerProvider.Shutdown, nil
}
// traceClientFromEnv creates a GRPC OTLP client based on OS environment
// variables.
//
// https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/
func traceClientFromEnv() (otlptrace.Client, envMap) {View on GitHub (pinned to ddc4b044b6)
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
Defensive patterns
Strategy: try-catch
Validate before calling
null // resource construction uses fixed internal attributes
Try / catch
// degrade gracefully: catch the InitTracing error, log a warning, run without tracing instead of aborting the CLI command
Prevention
- Use plain (attribute-safe) docker context names (letters, digits, dash, underscore)
- Pin a compose version whose OTEL SDK passes validation for your environment
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- loading otel config from docker context metadata: %w
- restoring env for %q: %w
- stashing env for %q: %w
- initializing otel connection from docker context metadata: %
- unexpected type for field %q: %T (expected: %T)
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/0b5b27ffa1e14bf6.
Report an issue: GitHub.