redis/go-redis · error
failed to create connection pending requests metric: %w
Error message
failed to create connection pending requests metric: %w
What it means
Returned by createRecorder when meter.Int64UpDownCounter fails to create the db.client.connection.pending_requests gauge (dbconv.ClientConnectionPendingRequests), the last instrument in the advanced connection group. Init fails with 'failed to create metrics recorder' and none of the previously created instruments take effect. The MeterProvider rejected instrument creation.
Source
Thrown at extra/redisotel-native/redisotel.go:301
}
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"),
metric.WithUnit("{message}"),
)
if err != nil {
return nil, fmt.Errorf("failed to create Pub/Sub messages metric: %w", err)
}
}
var streamLag metric.Float64Histogram
View on GitHub (pinned to c5cad058c7)
Solutions
- Align go.opentelemetry.io/otel and semconv/dbconv versions across all modules (go mod tidy)
- Use a fully supported MeterProvider (official sdkmetric) rather than custom/stub implementations; keep it alive for the process
- Check for duplicate db.client.connection.pending_requests registrations
- Unwrap the returned error and enable otel's error handler logs to see the exact SDK reason
- If unavailable, drop MetricGroupFlagConnectionAdvanced from Config.MetricGroups to skip these instruments
Example fix
// before
// mixed otel versions: semconv v1.38.0 dbconv with old metric SDK
err := obs.Init(cfg)
// after
go get go.opentelemetry.io/otel/metric@latest go.opentelemetry.io/otel/sdk/metric@latest
go mod tidy
err := obs.Init(&redisotel.Config{Enabled: true, MeterProvider: sdkmetric.NewMeterProvider(sdkmetric.WithReader(reader))}) Defensive patterns
Strategy: validation
Validate before calling
// before Init, confirm SDK version supports dbconv semconv v1.38.0 instruments
if !otelSemconvSupported { // e.g. check module version of go.opentelemetry.io/otel/sdk/metric
cfg.MetricGroups &^= redisotel.MetricGroupFlagConnectionAdvanced
} Try / catch
err := obs.Init(cfg)
if err != nil {
var unwrapped error = err
for errors.Unwrap(unwrapped) != nil { unwrapped = errors.Unwrap(unwrapped) }
log.Printf("redisotel: %v (cause: %v)", err, unwrapped)
} Prevention
- Run go mod tidy after otel upgrades to avoid version skew
- Use the official sdkmetric provider
- Check Init's returned error and its unwrap chain
- Skip unused metric groups to reduce failure surface
When it happens
Trigger: Init with MetricGroupFlagConnectionAdvanced enabled against a shut-down, no-op-with-error-handler, or strict MeterProvider; semconv/dbconv version mismatch producing an instrument spec the SDK rejects; duplicate name registration with conflicting unit.
Common situations: otel dependency skew after partial upgrades (dbconv from semconv v1.38.0 vs older SDK); test providers that error on UpDownCounter creation; graceful-shutdown code that stops the SDK before re-init attempts.
Related errors
- failed to create connection closed metric: %w
- failed to create operation duration histogram: %w
- failed to create connection count metric: %w
- failed to create connection create time histogram: %w
- failed to create connection relaxed timeout metric: %w
AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01).
Data as JSON: /api/errors/603a84175ccbece9.
Report an issue: GitHub.