{"record":{"id":"0a4b9a6e3730ea15","repo":"redis/go-redis","slug":"failed-to-create-stream-lag-histogram-w","errorCode":null,"errorMessage":"failed to create stream lag histogram: %w","messagePattern":"failed to create stream lag histogram: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extra/redisotel-native/redisotel.go","lineNumber":336,"sourceCode":"\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,\n\t\t\tstreamLagOpts...,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create stream lag histogram: %w\", err)\n\t\t}\n\t}\n\n\t// Create recorder\n\trecorder := &metricsRecorder{\n\t\toperationDuration:        operationDuration,\n\t\tconnectionCount:          connectionCount,\n\t\tconnectionCreateTime:     connectionCreateTime,\n\t\tconnectionRelaxedTimeout: connectionRelaxedTimeout,\n\t\tconnectionHandoff:        connectionHandoff,\n\t\tclientErrors:             clientErrors,\n\t\tmaintenanceNotifications: maintenanceNotifications,\n\t\tconnectionWaitTime:       connectionWaitTime,\n\t\tconnectionClosed:         connectionClosed,\n\t\tconnectionPendingReqs:    connectionPendingReqs,\n\t\tpubsubMessages:           pubsubMessages,\n\t\tstreamLag:                streamLag,\n\t\tcfg:                      &cfg,","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/extra/redisotel-native/redisotel.go#L318-L354","documentation":"During createRecorder in the native redisotel module, the Float64Histogram used to record Redis stream lag cannot be created by the OTel meter. The error is wrapped and returned from Init. Like error 90 this is an instrumentation setup failure, not a Redis-side error.","triggerScenarios":"redisotel.Init called with the stream metric group enabled and meter.Float64Histogram(MetricStreamLag, streamLagOpts...) returns an error from the OTel SDK.","commonSituations":"MeterProvider shutdown or not registered; explicit bucket boundaries passed via options rejected by the SDK; duplicate instrument creation with conflicting attributes/units in some SDK versions.","solutions":["Register a working MeterProvider before redisotel.Init","Inspect the wrapped underlying error for the SDK-specific cause","Review stream-lag histogram options (explicit buckets) for SDK incompatibilities","Disable the stream metrics group in config if not needed"],"exampleFix":"// before\nclient, err := redis.NewClient(opt)\nredisotel.Init(client) // mp already shut down\n// after\nmp := sdkmetric.NewMeterProvider()\ndefer mp.Shutdown(context.Background())\notel.SetMeterProvider(mp)\nredisotel.Init(client)","handlingStrategy":"validation","validationCode":"mp := sdkmetric.NewMeterProvider()\notel.SetMeterProvider(mp)\n// then\nif err := redisotel.Init(client); err != nil {\n\tlog.Fatalf(\"metrics init failed: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := redisotel.Init(client); err != nil {\n\tif strings.Contains(err.Error(), \"stream lag histogram\") {\n\t\t// fall back to no metrics\n\t\tlog.Printf(\"stream-lag metrics disabled: %v\", err)\n\t}\n}","preventionTips":["Initialize metrics SDK before instrumenting","Validate explicit histogram bucket options against the SDK version","Disable stream metric group if streams are unused"],"tags":["opentelemetry","metrics","histogram","streams"],"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"}