go-redis/redis · error

failed to create client errors metric: %w

Error message

failed to create client errors metric: %w

What it means

Returned by createRecorder (redisotel.go:255) when meter.Int64Counter fails to create the 'redis.client.errors' instrument. Only checked when MetricGroupResiliency is enabled.

Source

Thrown at extra/redisotel-native/redisotel.go:255

			MetricConnectionHandoff,
			metric.WithDescription("Connections that have been handed off to another node (e.g after a MOVING notification)"),
		)
		if err != nil {
			return nil, fmt.Errorf("failed to create connection handoff metric: %w", err)
		}
	}

	var clientErrors metric.Int64Counter
	var maintenanceNotifications metric.Int64Counter

	if cfg.isMetricGroupEnabled(MetricGroupResiliency) {
		clientErrors, err = meter.Int64Counter(
			MetricClientErrors,
			metric.WithDescription("Number of errors handled by the Redis client"),
			metric.WithUnit("{error}"),
		)
		if err != nil {
			return nil, fmt.Errorf("failed to create client errors metric: %w", err)
		}

		maintenanceNotifications, err = meter.Int64Counter(
			MetricMaintenanceNotifications,
			metric.WithDescription("Number of maintenance notifications received"),
			metric.WithUnit("{notification}"),
		)
		if err != nil {
			return nil, fmt.Errorf("failed to create maintenance notifications metric: %w", err)
		}
	}

	var connectionWaitTime metric.Float64Histogram
	var connectionClosed metric.Int64Counter
	var connectionPendingReqs metric.Int64UpDownCounter // OTel semconv: UpDownCounter

	if cfg.isMetricGroupEnabled(MetricGroupConnectionAdvanced) {
		var connectionWaitTimeOpts []metric.Float64HistogramOption

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Reconcile any other registration of 'redis.client.errors' so it uses Int64Counter with matching unit and description
  2. Run 'go mod graph' to check for conflicting redisotel versions
  3. Verify the MeterProvider is properly initialized before calling Init

Example fix

// before - another integration uses a different unit
meter.Int64Counter("redis.client.errors", metric.WithUnit("{errors}"))

// after - match redisotel's unit "{error}"
meter.Int64Counter("redis.client.errors", metric.WithUnit("{error}"))
Defensive patterns

Strategy: try-catch

Try / catch

if err := obs.Init(cfg); err != nil {
    if strings.Contains(err.Error(), "client errors metric") {
        log.Error("conflict on 'redis.client.errors'; reconcile unit '{error}' and description")
    }
}

Prevention

When it happens

Trigger: Calling Init with MetricGroupFlagResiliency enabled, and the OTel SDK rejects the Counter creation.

Common situations: Another library registered 'redis.client.errors' with conflicting metadata; multiple incompatible redisotel versions in the dependency tree; broken MeterProvider.

Related errors


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