{"id":"751a58141c9bce3e","repo":"go-redis/redis","slug":"failed-to-create-client-errors-metric-w","errorCode":null,"errorMessage":"failed to create client errors metric: %w","messagePattern":"failed to create client errors metric: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extra/redisotel-native/redisotel.go","lineNumber":255,"sourceCode":"\t\t\tMetricConnectionHandoff,\n\t\t\tmetric.WithDescription(\"Connections that have been handed off to another node (e.g after a MOVING notification)\"),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create connection handoff metric: %w\", err)\n\t\t}\n\t}\n\n\tvar clientErrors metric.Int64Counter\n\tvar maintenanceNotifications metric.Int64Counter\n\n\tif cfg.isMetricGroupEnabled(MetricGroupResiliency) {\n\t\tclientErrors, err = meter.Int64Counter(\n\t\t\tMetricClientErrors,\n\t\t\tmetric.WithDescription(\"Number of errors handled by the Redis client\"),\n\t\t\tmetric.WithUnit(\"{error}\"),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create client errors metric: %w\", err)\n\t\t}\n\n\t\tmaintenanceNotifications, err = meter.Int64Counter(\n\t\t\tMetricMaintenanceNotifications,\n\t\t\tmetric.WithDescription(\"Number of maintenance notifications received\"),\n\t\t\tmetric.WithUnit(\"{notification}\"),\n\t\t)\n\t\tif err != nil {\n\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","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/extra/redisotel-native/redisotel.go#L237-L273","documentation":"Returned by createRecorder (redisotel.go:255) when meter.Int64Counter fails to create the 'redis.client.errors' instrument. Only checked when MetricGroupResiliency is enabled.","triggerScenarios":"Calling Init with MetricGroupFlagResiliency enabled, and the OTel SDK rejects the Counter creation.","commonSituations":"Another library registered 'redis.client.errors' with conflicting metadata; multiple incompatible redisotel versions in the dependency tree; broken MeterProvider.","solutions":["Reconcile any other registration of 'redis.client.errors' so it uses Int64Counter with matching unit and description","Run 'go mod graph' to check for conflicting redisotel versions","Verify the MeterProvider is properly initialized before calling Init"],"exampleFix":"// before - another integration uses a different unit\nmeter.Int64Counter(\"redis.client.errors\", metric.WithUnit(\"{errors}\"))\n\n// after - match redisotel's unit \"{error}\"\nmeter.Int64Counter(\"redis.client.errors\", metric.WithUnit(\"{error}\"))","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := obs.Init(cfg); err != nil {\n    if strings.Contains(err.Error(), \"client errors metric\") {\n        log.Error(\"conflict on 'redis.client.errors'; reconcile unit '{error}' and description\")\n    }\n}","preventionTips":["Ensure no other library registers 'redis.client.errors' with conflicting metadata","Run 'go mod graph' to detect conflicting redisotel versions","Verify MeterProvider validity before Init"],"tags":["otel","redisotel-native","metrics","resiliency","counter"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}