{"id":"50edce3fddbc3236","repo":"go-redis/redis","slug":"failed-to-create-connection-wait-time-histogram","errorCode":null,"errorMessage":"failed to create connection wait time histogram: %w","messagePattern":"failed to create connection wait time histogram: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extra/redisotel-native/redisotel.go","lineNumber":282,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"failed to create maintenance notifications metric: %w\", err)\n\t\t}\n\t}\n\n\tvar connectionWaitTime metric.Float64Histogram\n\tvar connectionClosed metric.Int64Counter\n\tvar connectionPendingReqs metric.Int64UpDownCounter // OTel semconv: UpDownCounter\n\n\tif cfg.isMetricGroupEnabled(MetricGroupConnectionAdvanced) {\n\t\tvar connectionWaitTimeOpts []metric.Float64HistogramOption\n\t\tif cfg.histAggregation == HistogramAggregationExplicitBucket {\n\t\t\tconnectionWaitTimeOpts = append(connectionWaitTimeOpts,\n\t\t\t\tmetric.WithExplicitBucketBoundaries(cfg.bucketsConnectionWaitTime...),\n\t\t\t)\n\t\t}\n\t\tvar connectionWaitTimeConv dbconv.ClientConnectionWaitTime\n\t\tconnectionWaitTimeConv, err = dbconv.NewClientConnectionWaitTime(meter, connectionWaitTimeOpts...)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create connection wait time histogram: %w\", err)\n\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 {","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/extra/redisotel-native/redisotel.go#L264-L300","documentation":"Returned by createRecorder (redisotel.go:282) when dbconv.NewClientConnectionWaitTime fails to create the 'db.client.connection.wait_time' Float64Histogram. Only checked when MetricGroupConnectionAdvanced is enabled.","triggerScenarios":"Calling Init with MetricGroupFlagConnectionAdvanced enabled, and the OTel SDK rejects the histogram creation.","commonSituations":"Another library registered 'db.client.connection.wait_time' with conflicting unit or description; malformed cfg.BucketsConnectionWaitTime boundary values.","solutions":["Search for other registrations of 'db.client.connection.wait_time' and reconcile metadata","Validate cfg.BucketsConnectionWaitTime contains monotonically increasing positive floats","Verify OTel SDK compatibility"],"exampleFix":"// before - bucket boundaries invalid\ncfg.BucketsConnectionWaitTime = []float64{0}\n\n// after - valid positive monotonically increasing bounds\ncfg.BucketsConnectionWaitTime = []float64{0.001, 0.01, 0.1, 1.0}","handlingStrategy":"try-catch","validationCode":"// Validate connection wait time bucket boundaries\nfor i := 1; i < len(cfg.BucketsConnectionWaitTime); i++ {\n    if cfg.BucketsConnectionWaitTime[i] <= cfg.BucketsConnectionWaitTime[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(), \"connection wait time histogram\") {\n        log.Error(\"conflict on 'db.client.connection.wait_time' or invalid bucket boundaries\")\n    }\n}","preventionTips":["Ensure no other library registers 'db.client.connection.wait_time' with conflicting metadata","Validate histogram bucket boundaries are monotonically increasing","Use a compatible OTel SDK version"],"tags":["otel","redisotel-native","metrics","connection","histogram"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}