{"id":"910b30046caa94f4","repo":"go-redis/redis","slug":"failed-to-create-connection-count-metric-w","errorCode":null,"errorMessage":"failed to create connection count metric: %w","messagePattern":"failed to create connection count metric: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extra/redisotel-native/redisotel.go","lineNumber":211,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create operation duration histogram: %w\", err)\n\t\t}\n\t\toperationDuration = operationDurationConv.Inst()\n\t}\n\n\tvar connectionCount metric.Int64UpDownCounter // OTel semconv: UpDownCounter\n\tvar connectionCreateTime metric.Float64Histogram\n\tvar connectionRelaxedTimeout metric.Int64UpDownCounter\n\tvar connectionHandoff metric.Int64Counter\n\n\tif cfg.isMetricGroupEnabled(MetricGroupConnectionBasic) {\n\t\tconnectionCount, err = meter.Int64UpDownCounter(\n\t\t\tdbconv.ClientConnectionCount{}.Name(),\n\t\t\tmetric.WithDescription(dbconv.ClientConnectionCount{}.Description()),\n\t\t\tmetric.WithUnit(dbconv.ClientConnectionCount{}.Unit()),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create connection count metric: %w\", err)\n\t\t}\n\n\t\tvar connectionCreateTimeOpts []metric.Float64HistogramOption\n\t\tif cfg.histAggregation == HistogramAggregationExplicitBucket {\n\t\t\tconnectionCreateTimeOpts = append(connectionCreateTimeOpts,\n\t\t\t\tmetric.WithExplicitBucketBoundaries(cfg.bucketsConnectionCreateTime...),\n\t\t\t)\n\t\t}\n\t\tvar connectionCreateTimeConv dbconv.ClientConnectionCreateTime\n\t\tconnectionCreateTimeConv, err = dbconv.NewClientConnectionCreateTime(meter, connectionCreateTimeOpts...)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create connection create time histogram: %w\", err)\n\t\t}\n\t\tconnectionCreateTime = connectionCreateTimeConv.Inst()\n\n\t\tconnectionRelaxedTimeout, err = meter.Int64UpDownCounter(\n\t\t\tMetricConnectionRelaxedTimeout,\n\t\t\tmetric.WithDescription(\"How many times the connection timeout has been increased/decreased (after a server maintenance notification)\"),","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/extra/redisotel-native/redisotel.go#L193-L229","documentation":"Returned by createRecorder (redisotel.go:211) when meter.Int64UpDownCounter fails to create the 'db.client.connection.count' instrument. Only checked when MetricGroupConnectionBasic is enabled. The wrapped error comes from the OTel SDK.","triggerScenarios":"Calling Init with MetricGroupFlagConnectionBasic enabled, and the OTel SDK rejects the UpDownCounter creation.","commonSituations":"Another instrumentation library or a second redisotel Init call registered 'db.client.connection.count' with a conflicting instrument type (e.g., Counter instead of UpDownCounter) or different metadata; incompatible OTel SDK.","solutions":["Find and reconcile any other registration of 'db.client.connection.count' so the instrument type and metadata match","Ensure only one redisotel-native Init runs per process (the initialized guard prevents this, but other OTel integrations may conflict)","Verify the MeterProvider and SDK version are compatible"],"exampleFix":"// before - another lib registers the same name as a Counter\nmeter.Int64Counter(\"db.client.connection.count\") // type mismatch\n\n// after - use UpDownCounter to match redisotel semconv\nmeter.Int64UpDownCounter(\"db.client.connection.count\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := obs.Init(cfg); err != nil {\n    if strings.Contains(err.Error(), \"connection count metric\") {\n        log.Error(\"conflict on 'db.client.connection.count'; another lib registered it with conflicting type/metadata\")\n    }\n}","preventionTips":["Ensure no other integration registers 'db.client.connection.count' as a different instrument type","Run 'go mod graph' to detect conflicting redisotel versions","Reconcile unit and description metadata across all OTel integrations"],"tags":["otel","redisotel-native","metrics","connection","updown-counter"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}