Files
ee6e9dbf09 feat(otel): Add OpenTelemetry Native Metrics Support (#3637)
* First draft. One metric - command duration.

Signed-off-by: Elena Kolevska <[email protected]>

* Adds connection state metrics

Signed-off-by: Elena Kolevska <[email protected]>

* wip

Signed-off-by: Elena Kolevska <[email protected]>

* Add phase 1 metrics

* Add client api configurations

* remove redundent code

* refactor: move otel-metrics example to separate module

* refactor: move otel-metrics example to separate module

* remove internal test

* Resolve merge conflicts with upstream/master

* Fix linting issues

* Fix pool idle connection counter bug

* Add OTel performance benchmarking suite

* Improve perf compatison script

* Add phase 2,3 metrics

* Remove local benchmark tests

* Add new fields to tests

* Change db.client.connection.count and db.client.connection.pending_request metric type from UpAndDownCounter to Async gauge.

* fix golangci lint

* Add piplined commands metrics support

* Redesign otel init method

* Address comments

* Fix golangci-lint errors

* Fix passing nil pointer

* Add metric prefix to callbacks and atomic batch registration

* Add unique name for pool.name attr

* Fix unique pool name for pubsub

* Refactor all hardcoded OTel attribute strings to use constants

* Refactor all hardcoded OTel attribute strings to use constants

* extract metric names and pool names as constants, improve error handling

---------

Signed-off-by: Elena Kolevska <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
2026-02-13 18:08:10 +02:00

68 lines
2.2 KiB
Go

package redisotel
// OpenTelemetry semantic convention attribute keys for Redis client metrics.
// These constants follow the OTel semantic conventions for database clients.
// Reference: https://opentelemetry.io/docs/specs/semconv/database/redis/
const (
// Database semantic convention attributes
AttrDBSystemName = "db.system.name"
AttrDBNamespace = "db.namespace"
AttrDBOperationName = "db.operation.name"
AttrDBOperationBatchSize = "db.operation.batch.size"
AttrDBResponseStatusCode = "db.response.status_code"
// Connection pool attributes
AttrDBClientConnectionPoolName = "db.client.connection.pool.name"
AttrDBClientConnectionState = "db.client.connection.state"
// Server attributes
AttrServerAddress = "server.address"
AttrServerPort = "server.port"
// Network attributes
AttrNetworkPeerAddress = "network.peer.address"
AttrNetworkPeerPort = "network.peer.port"
// Error attributes
AttrErrorType = "error.type"
// Redis-specific attributes
AttrRedisClientLibrary = "redis.client.library"
AttrRedisClientConnectionPubSub = "redis.client.connection.pubsub"
AttrRedisClientConnectionCloseReason = "redis.client.connection.close.reason"
AttrRedisClientErrorsCategory = "redis.client.errors.category"
AttrRedisClientErrorsInternal = "redis.client.errors.internal"
AttrRedisClientOperationRetryAttempts = "redis.client.operation.retry_attempts"
// PubSub attributes
AttrRedisClientPubSubDirection = "redis.client.pubsub.direction"
AttrRedisClientPubSubSharded = "redis.client.pubsub.sharded"
AttrRedisClientPubSubChannel = "redis.client.pubsub.channel"
// Stream attributes
AttrRedisClientStreamName = "redis.client.stream.name"
AttrRedisClientStreamConsumerGroup = "redis.client.stream.consumer_group"
AttrRedisClientStreamConsumerName = "redis.client.stream.consumer_name"
// Notification attributes
AttrRedisClientConnectionNotification = "redis.client.connection.notification"
)
// Connection state values
const (
ConnectionStateIdle = "idle"
ConnectionStateUsed = "used"
)
// PubSub direction values
const (
PubSubDirectionSent = "sent"
PubSubDirectionReceived = "received"
)
// DB system value
const (
DBSystemRedis = "redis"
)