{"record":{"id":"db6c6cb049ea46bb","repo":"redis/go-redis","slug":"failed-to-create-pub-sub-messages-metric-w","errorCode":null,"errorMessage":"failed to create Pub/Sub messages metric: %w","messagePattern":"failed to create Pub/Sub messages metric: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extra/redisotel-native/redisotel.go","lineNumber":314,"sourceCode":"\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\n\tif cfg.isMetricGroupEnabled(MetricGroupStream) {\n\t\tvar streamLagOpts []metric.Float64HistogramOption\n\t\tstreamLagOpts = append(streamLagOpts,\n\t\t\tmetric.WithDescription(\"The lag between message creation and consumption in a stream consumer group\"),\n\t\t\tmetric.WithUnit(\"s\"),\n\t\t)\n\t\tif cfg.histAggregation == HistogramAggregationExplicitBucket {\n\t\t\tstreamLagOpts = append(streamLagOpts,\n\t\t\t\tmetric.WithExplicitBucketBoundaries(cfg.bucketsStreamProcessingDuration...),\n\t\t\t)\n\t\t}\n\t\tstreamLag, err = meter.Float64Histogram(\n\t\t\tMetricStreamLag,","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/extra/redisotel-native/redisotel.go#L296-L332","documentation":"Instrumentation of the native redisotel module creates OpenTelemetry metric instruments at recorder-init time. When the OTel meter cannot instantiate the Int64Counter for pub/sub message counts (e.g. a broken or nil MeterProvider, invalid instrument name/unit, or a failing SDK), createRecorder wraps and returns the underlying error. This is a startup-time failure, not a Redis connection problem.","triggerScenarios":"redisotel.Init / InstrumentMetrics (native path) calls createRecorder with a metric group including Pub/Sub enabled and meter.Int64Counter returns an error — typically a misconfigured global MeterProvider, an SDK that rejects the instrument, or an invalid custom meter.","commonSituations":"OTel SDK not registered or shut down before Init; using a Noop/noop meter wrapper with strict validation; name/unit conflicts with instrumention-level limits; custom WithMeter option passing an incompatible meter implementation.","solutions":["Check that a valid OTel MeterProvider is registered via otel.SetMeterProvider before calling redisotel.Init","Print the wrapped error (%w) to see the root cause from the meter SDK","Verify the meter implements go.opentelemetry.io/otel/metric.Meter correctly and is not shut down","Disable the metrics group via config options if metrics are not needed"],"exampleFix":"// before\nerr := redisotel.Init(client) // uses broken/absent MeterProvider\n// after\notel.SetMeterProvider(sdktrace.NewTracerProvider()) // plus metric provider\nerr := redisotel.Init(client)","handlingStrategy":"validation","validationCode":"if otel.GetMeterProvider() == nil || isShutdown(otel.GetMeterProvider()) {\n\totel.SetMeterProvider(sdkmetric.NewMeterProvider())\n}\nerr := redisotel.Init(client)","typeGuard":null,"tryCatchPattern":"if err := redisotel.Init(client); err != nil {\n\tif strings.Contains(err.Error(), \"Pub/Sub messages metric\") {\n\t\tlog.Fatalf(\"otel meter misconfigured: %v\", err)\n\t}\n}","preventionTips":["Register the OTel MeterProvider before redisotel.Init","Never shut down the MeterProvider before the client is closed","Pin compatible otel SDK versions with go-redis"],"tags":["opentelemetry","metrics","initialization"],"backgroundTag":"otel-meter-creation-failed","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}