go-redis/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 (redisotel.go:301) when meter.Int64UpDownCounter fails to create the 'db.client.connection.pending_requests' instrument. Only checked when MetricGroupConnectionAdvanced is enabled.

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 36d97525cd)

Solutions

  1. Reconcile other registrations of 'db.client.connection.pending_requests' to use Int64UpDownCounter with matching metadata
  2. Resolve redisotel version conflicts via go mod tidy
  3. Verify MeterProvider validity

Example fix

// before - another lib uses Counter instead of UpDownCounter
meter.Int64Counter("db.client.connection.pending_requests")

// after - match redisotel's UpDownCounter type
meter.Int64UpDownCounter("db.client.connection.pending_requests")
Defensive patterns

Strategy: try-catch

Try / catch

if err := obs.Init(cfg); err != nil {
    if strings.Contains(err.Error(), "connection pending requests metric") {
        log.Error("conflict on 'db.client.connection.pending_requests'; ensure UpDownCounter type match")
    }
}

Prevention

When it happens

Trigger: Calling Init with MetricGroupFlagConnectionAdvanced enabled, and the OTel SDK rejects the UpDownCounter creation.

Common situations: Another library registered 'db.client.connection.pending_requests' with a conflicting instrument type or metadata; conflicting redisotel versions; broken MeterProvider.

Related errors


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/6dfb00a2cd677165.json. Report an issue: GitHub.