{"record":{"id":"72402e35fc38b7b1","repo":"caddyserver/caddy","slug":"creating-resource-error-w","errorCode":null,"errorMessage":"creating resource error: %w","messagePattern":"creating resource error: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddyhttp/tracing/tracer.go","lineNumber":62,"sourceCode":"// newOpenTelemetryWrapper is responsible for the openTelemetryWrapper initialization using provided configuration.\nfunc newOpenTelemetryWrapper(\n\tctx context.Context,\n\tspanName string,\n\tspanAttributes map[string]string,\n) (openTelemetryWrapper, error) {\n\tif spanName == \"\" {\n\t\tspanName = defaultSpanName\n\t}\n\n\tot := openTelemetryWrapper{\n\t\tspanName:       spanName,\n\t\tspanAttributes: spanAttributes,\n\t}\n\n\tversion, _ := caddy.Version()\n\tres, err := ot.newResource(caddyhttp.ServerHeader, version)\n\tif err != nil {\n\t\treturn ot, fmt.Errorf(\"creating resource error: %w\", err)\n\t}\n\n\tot.propagators = autoprop.NewTextMapPropagator()\n\n\t// Defer creation of the exporter (and its batch span processor goroutine)\n\t// until we know a new provider is actually needed. When the global provider\n\t// already exists it is reused and these options are discarded; building them\n\t// here unconditionally would leak the exporter and a BatchSpanProcessor\n\t// goroutine on every config reload.\n\ttracerProvider, err := globalTracerProvider.getTracerProvider(func() ([]sdktrace.TracerProviderOption, error) {\n\t\ttraceExporter, err := autoexport.NewSpanExporter(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"creating trace exporter error: %w\", err)\n\t\t}\n\n\t\treturn []sdktrace.TracerProviderOption{\n\t\t\tsdktrace.WithBatcher(traceExporter),\n\t\t\tsdktrace.WithResource(res),","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/tracing/tracer.go#L44-L80","documentation":"Returned while constructing the OpenTelemetry wrapper for the tracing module when ot.newResource fails. The resource carries service.name (from the ServerHeader/version args) built via resource.New with attributes; failure means resource construction options were rejected by the otel SDK.","triggerScenarios":"Provisioning the tracing handler when resource.New returns an error, commonly from invalid OTEL_RESOURCE_ATTRIBUTES / OTEL_SERVICE_NAME environment variable values (malformed key=value pairs) or conflicting resource-merge options in the otel SDK version in use.","commonSituations":"Deployments setting OTEL_RESOURCE_ATTRIBUTES with bad syntax ('service.name foo' without '='), duplicated service name sources, or older/newer otel SDKs in custom builds with different validation strictness.","solutions":["Check the wrapped error for the offending attribute key/value","Fix env vars: OTEL_SERVICE_NAME=myapp, OTEL_RESOURCE_ATTRIBUTES=\"key=value,key2=value2\"","Unset or sanitize custom OTEL_* vars and retry provisioning (`caddy validate` with tracing in config)","In custom builds, align otel library versions with what Caddy's tracing module expects"],"exampleFix":"# before\nexport OTEL_RESOURCE_ATTRIBUTES=\"service.name myapp,deployment.env prod\"\n\n# after\nexport OTEL_SERVICE_NAME=myapp\nexport OTEL_RESOURCE_ATTRIBUTES=\"deployment.env=prod\"","handlingStrategy":"validation","validationCode":"# shell: verify OTEL env before starting caddy\n[ -n \"$OTEL_SERVICE_NAME\" ] || export OTEL_SERVICE_NAME=myapp\necho \"$OTEL_RESOURCE_ATTRIBUTES\" | tr ',' '\\n' | grep -vE '^[A-Za-z0-9_.\\-/]+=.+$' && { echo 'bad OTEL_RESOURCE_ATTRIBUTES' >&2; exit 1; } || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set OTEL_SERVICE_NAME instead of encoding it in OTEL_RESOURCE_ATTRIBUTES","Use strict key=value,key=value syntax with no spaces around '='","Run `caddy validate --config` with tracing env present in CI"],"tags":["caddy","tracing","opentelemetry","environment"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}