{"record":{"id":"b3936da5f70c2331","repo":"redis/go-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/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/extra/redisotel-native/redisotel.go#L264-L300","documentation":"Returned by createRecorder when dbconv.NewClientConnectionWaitTime fails to create the db.client.connection.wait_time histogram (advanced connection metric group). Init aborts with 'failed to create metrics recorder', so pool wait-time metrics are never installed. Root cause is MeterProvider-level instrument creation failure.","triggerScenarios":"Init with MetricGroupFlagConnectionAdvanced enabled, HistogramAggregationExplicitBucket set, and invalid BucketsConnectionWaitTime (empty, non-increasing, or non-positive); or a MeterProvider that is shut down / rejects the dbconv semconv instrument.","commonSituations":"Operators copying bucket configs from other services with malformed values; provider lifecycle bugs in tests; upgrading otel SDK so histogram validation tightened.","solutions":["Fix BucketsConnectionWaitTime so boundaries are strictly increasing positive floats","Fall back to HistogramAggregationDefault if explicit buckets are not essential","Ensure the MeterProvider is running before Init and not previously Shutdown","Unwrap the error and check otel's global error handler for the precise rejection","Upgrade/align go.opentelemetry.io/otel versions across modules"],"exampleFix":"// before\ncfg.BucketsConnectionWaitTime = []float64{1, 0.5, 0.1} // decreasing\n// after\ncfg.BucketsConnectionWaitTime = []float64{0.0001, 0.001, 0.01, 0.1, 1, 10}","handlingStrategy":"validation","validationCode":"func bucketsOK(b []float64) bool {\n    if len(b) == 0 { return false }\n    for i := 1; i < len(b); i++ { if b[i] <= b[i-1] { return false } }\n    return b[0] > 0\n}\nif !bucketsOK(cfg.BucketsConnectionWaitTime) {\n    cfg.HistogramAggregation = redisotel.HistogramAggregationDefault\n}","typeGuard":null,"tryCatchPattern":"err := obs.Init(cfg)\nif err != nil && strings.Contains(err.Error(), \"connection wait time histogram\") {\n    cfg.BucketsConnectionWaitTime = defaultWaitTimeBuckets\n    err = obs.Init(cfg)\n}","preventionTips":["Sort and validate bucket boundaries in config loading","Unit-test Init with your production Config","Keep otel SDK current","Check Init errors at boot"],"tags":["opentelemetry","metrics","histogram","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"}