Skip to content

unexpected used connections metric reported when using StreamingCredentialsProvider #3542

@yolu16

Description

@yolu16

Issue tracker is used for reporting bugs and discussing new features. Please use
stackoverflow for supporting issues.

We're migrating from CredentialsProviderContext to StreamingCredentialsProvider for EntraID authentication using go-redis-entraid. A few hours after deploying this change, we observed a large increase in db.client.connections.usage in the "used" state, while the "idle" state remained stable. This behavior did not occur with CredentialsProviderContext, so we're unsure if it's related to the new provider.

Expected Behavior

We do not expect the db.client.connections.usage in the "used" state to have a sudden large increase.

Current Behavior

The number of db.client.connections.usage in "used" state is stable with value X and suddenly increases to 4,294,967,295+X. Not sure if it's a coincidence, 4,294,967,295 is the max value of uint32.
The db.client.connections.usage "idle" state remains stable during the sudden increase.
The metrics are set up with redisotel.InstrumentMetrics(client)

Graph of used and idle connections
Image
Used connections data (4,294,967,295 + 1)
Image
Idle connections data
Image

Steps to Reproduce

Unfortunately, we did not see anything special that could have caused this state, it just seemed to occur spontaneously a few hours after deploying our service. We only create one RedisClient in our service code and use it for all our redis operations.
Here is a sample of our redis client configs:

type RedisConfig struct {
	Host          string
	Port          int
}

func NewRedisClient(redisConfig RedisConfig) (redis.UniversalClient, error) {
	address := fmt.Sprintf("%s:%d", redisConfig.Host, redisConfig.Port)

	provider, err := entraid.NewDefaultAzureCredentialsProvider(entraid.DefaultAzureCredentialsProviderOptions{
		DefaultAzureIdentityProviderOptions: identity.DefaultAzureIdentityProviderOptions{
			Scopes: []string{"https://redis.azure.com/.default"},
		},
	})
	if err != nil {
		return nil, err
	}

	opt := &redis.ClusterOptions{
		Addrs:                        []string{address},
		StreamingCredentialsProvider: provider,
		TLSConfig: &tls.Config{
			ServerName: redisConfig.Host,
			MinVersion: tls.VersionTLS12,
		},
	}

	client := redis.NewClusterClient(opt)

	if err := redisotel.InstrumentTracing(client); err != nil {
		return nil, err
	}

	if err := redisotel.InstrumentMetrics(client); err != nil {
		return nil, err
	}

	return client, nil
}

Context (Environment)

go 1.25.0
go-redis/v9 v9.14.0
go-redis/extra/redisotel/v9 v9.14.0
go-redis-entraid v1.0.6

Our service is deployed on AKS with three active instances running concurrently. We are using Azure Managed Redis and Managed identities for auth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions