{"id":"975da5fbc7d1415b","repo":"go-redis/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/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/extra/redisotel-native/redisotel.go#L318-L354","documentation":"Returned by createRecorder (redisotel.go:336) when meter.Float64Histogram fails to create the 'redis.client.stream.lag' instrument. Only checked when MetricGroupStream is enabled.","triggerScenarios":"Calling Init with MetricGroupFlagStream enabled, and the OTel SDK rejects the histogram creation.","commonSituations":"Another library registered 'redis.client.stream.lag' with conflicting unit or description; malformed cfg.BucketsStreamLag boundary values when using explicit bucket aggregation.","solutions":["Search for other registrations of 'redis.client.stream.lag' and reconcile unit ('s') and description metadata","Validate cfg.BucketsStreamLag contains monotonically increasing positive float64 values","Verify OTel SDK compatibility"],"exampleFix":"// before - bucket boundaries non-monotonic\ncfg.BucketsStreamLag = []float64{10, 1, 100}\n\n// after - monotonically increasing\ncfg.BucketsStreamLag = []float64{1, 10, 100}","handlingStrategy":"try-catch","validationCode":"// Validate stream lag bucket boundaries\nfor i := 1; i < len(cfg.BucketsStreamLag); i++ {\n    if cfg.BucketsStreamLag[i] <= cfg.BucketsStreamLag[i-1] {\n        return fmt.Errorf(\"invalid bucket boundaries\")\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := obs.Init(cfg); err != nil {\n    if strings.Contains(err.Error(), \"stream lag histogram\") {\n        log.Error(\"conflict on 'redis.client.stream.lag' or invalid bucket boundaries\")\n    }\n}","preventionTips":["Ensure no other library registers 'redis.client.stream.lag' with conflicting unit ('s') or description","Validate cfg.BucketsStreamLag contains monotonically increasing positive values","Verify OTel SDK compatibility"],"tags":["otel","redisotel-native","metrics","stream","histogram"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}