{"record":{"id":"603a84175ccbece9","repo":"redis/go-redis","slug":"failed-to-create-connection-pending-requests-metri","errorCode":null,"errorMessage":"failed to create connection pending requests metric: %w","messagePattern":"failed to create connection pending requests metric: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extra/redisotel-native/redisotel.go","lineNumber":301,"sourceCode":"\t\t}\n\t\tconnectionWaitTime = connectionWaitTimeConv.Inst()\n\n\t\tconnectionClosed, err = meter.Int64Counter(\n\t\t\tMetricConnectionClosed,\n\t\t\tmetric.WithDescription(\"The number of connections that have been closed\"),\n\t\t\tmetric.WithUnit(\"{connection}\"),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create connection closed metric: %w\", err)\n\t\t}\n\n\t\tconnectionPendingReqs, err = meter.Int64UpDownCounter(\n\t\t\tdbconv.ClientConnectionPendingRequests{}.Name(),\n\t\t\tmetric.WithDescription(dbconv.ClientConnectionPendingRequests{}.Description()),\n\t\t\tmetric.WithUnit(dbconv.ClientConnectionPendingRequests{}.Unit()),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create connection pending requests metric: %w\", err)\n\t\t}\n\t}\n\n\tvar pubsubMessages metric.Int64Counter\n\n\tif cfg.isMetricGroupEnabled(MetricGroupPubSub) {\n\t\tpubsubMessages, err = meter.Int64Counter(\n\t\t\tMetricPubSubMessages,\n\t\t\tmetric.WithDescription(\"The number of Pub/Sub messages sent or received\"),\n\t\t\tmetric.WithUnit(\"{message}\"),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create Pub/Sub messages metric: %w\", err)\n\t\t}\n\t}\n\n\tvar streamLag metric.Float64Histogram\n","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/extra/redisotel-native/redisotel.go#L283-L319","documentation":"Returned by createRecorder when meter.Int64UpDownCounter fails to create the db.client.connection.pending_requests gauge (dbconv.ClientConnectionPendingRequests), the last instrument in the advanced connection group. Init fails with 'failed to create metrics recorder' and none of the previously created instruments take effect. The MeterProvider rejected instrument creation.","triggerScenarios":"Init with MetricGroupFlagConnectionAdvanced enabled against a shut-down, no-op-with-error-handler, or strict MeterProvider; semconv/dbconv version mismatch producing an instrument spec the SDK rejects; duplicate name registration with conflicting unit.","commonSituations":"otel dependency skew after partial upgrades (dbconv from semconv v1.38.0 vs older SDK); test providers that error on UpDownCounter creation; graceful-shutdown code that stops the SDK before re-init attempts.","solutions":["Align go.opentelemetry.io/otel and semconv/dbconv versions across all modules (go mod tidy)","Use a fully supported MeterProvider (official sdkmetric) rather than custom/stub implementations; keep it alive for the process","Check for duplicate db.client.connection.pending_requests registrations","Unwrap the returned error and enable otel's error handler logs to see the exact SDK reason","If unavailable, drop MetricGroupFlagConnectionAdvanced from Config.MetricGroups to skip these instruments"],"exampleFix":"// before\n// mixed otel versions: semconv v1.38.0 dbconv with old metric SDK\nerr := obs.Init(cfg)\n// after\ngo get go.opentelemetry.io/otel/metric@latest go.opentelemetry.io/otel/sdk/metric@latest\ngo mod tidy\nerr := obs.Init(&redisotel.Config{Enabled: true, MeterProvider: sdkmetric.NewMeterProvider(sdkmetric.WithReader(reader))})","handlingStrategy":"validation","validationCode":"// before Init, confirm SDK version supports dbconv semconv v1.38.0 instruments\nif !otelSemconvSupported { // e.g. check module version of go.opentelemetry.io/otel/sdk/metric\n    cfg.MetricGroups &^= redisotel.MetricGroupFlagConnectionAdvanced\n}","typeGuard":null,"tryCatchPattern":"err := obs.Init(cfg)\nif err != nil {\n    var unwrapped error = err\n    for errors.Unwrap(unwrapped) != nil { unwrapped = errors.Unwrap(unwrapped) }\n    log.Printf(\"redisotel: %v (cause: %v)\", err, unwrapped)\n}","preventionTips":["Run go mod tidy after otel upgrades to avoid version skew","Use the official sdkmetric provider","Check Init's returned error and its unwrap chain","Skip unused metric groups to reduce failure surface"],"tags":["opentelemetry","metrics","connection-pool","go"],"backgroundTag":"otel-instrument-creation-failed","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}