go-redis/redis · error
failed to create connection closed metric: %w
Error message
failed to create connection closed metric: %w
What it means
Returned by createRecorder (redisotel.go:292) when meter.Int64Counter fails to create the 'redis.client.connection.closed' instrument. Only checked when MetricGroupConnectionAdvanced is enabled.
Source
Thrown at extra/redisotel-native/redisotel.go:292
if cfg.histAggregation == HistogramAggregationExplicitBucket {
connectionWaitTimeOpts = append(connectionWaitTimeOpts,
metric.WithExplicitBucketBoundaries(cfg.bucketsConnectionWaitTime...),
)
}
var connectionWaitTimeConv dbconv.ClientConnectionWaitTime
connectionWaitTimeConv, err = dbconv.NewClientConnectionWaitTime(meter, connectionWaitTimeOpts...)
if err != nil {
return nil, fmt.Errorf("failed to create connection wait time histogram: %w", err)
}
connectionWaitTime = connectionWaitTimeConv.Inst()
connectionClosed, err = meter.Int64Counter(
MetricConnectionClosed,
metric.WithDescription("The number of connections that have been closed"),
metric.WithUnit("{connection}"),
)
if err != nil {
return nil, fmt.Errorf("failed to create connection closed metric: %w", err)
}
connectionPendingReqs, err = meter.Int64UpDownCounter(
dbconv.ClientConnectionPendingRequests{}.Name(),
metric.WithDescription(dbconv.ClientConnectionPendingRequests{}.Description()),
metric.WithUnit(dbconv.ClientConnectionPendingRequests{}.Unit()),
)
if err != nil {
return nil, fmt.Errorf("failed to create connection pending requests metric: %w", err)
}
}
var pubsubMessages metric.Int64Counter
if cfg.isMetricGroupEnabled(MetricGroupPubSub) {
pubsubMessages, err = meter.Int64Counter(
MetricPubSubMessages,
metric.WithDescription("The number of Pub/Sub messages sent or received"),View on GitHub (pinned to 36d97525cd)
Solutions
- Reconcile other registrations of 'redis.client.connection.closed' to use Int64Counter with matching unit '{connection}' and description
- Resolve redisotel version conflicts in the dependency tree
- Verify MeterProvider validity
Example fix
// before - conflicting unit from another integration
meter.Int64Counter("redis.client.connection.closed", metric.WithUnit("{closed}"))
// after - match redisotel's unit
meter.Int64Counter("redis.client.connection.closed", metric.WithUnit("{connection}")) Defensive patterns
Strategy: try-catch
Try / catch
if err := obs.Init(cfg); err != nil {
if strings.Contains(err.Error(), "connection closed metric") {
log.Error("conflict on 'redis.client.connection.closed'; reconcile unit and description")
}
} Prevention
- Ensure no other integration registers 'redis.client.connection.closed' with conflicting metadata
- Resolve redisotel version conflicts in the dependency tree
- Verify MeterProvider validity
When it happens
Trigger: Calling Init with MetricGroupFlagConnectionAdvanced enabled, and the OTel SDK rejects the Counter creation.
Common situations: Another library registered 'redis.client.connection.closed' with conflicting metadata; conflicting redisotel versions; broken MeterProvider.
Related errors
- failed to create connection handoff metric: %w
- failed to create connection count metric: %w
- failed to create connection create time histogram: %w
- failed to create connection relaxed timeout metric: %w
- failed to create client errors metric: %w
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/3eceddab2c5232ac.json.
Report an issue: GitHub.