Redis.OpenTelemetry (Redis v0.8.0)

Copy Markdown View Source

Optional OpenTelemetry integration for Redis.

Creates OTel spans for Redis commands by attaching to the existing :telemetry events emitted by Redis.Telemetry. Requires the :opentelemetry_api dependency.

Setup

# In your application startup:
Redis.OpenTelemetry.attach()

Span Attributes

Follows the OpenTelemetry semantic conventions for databases:

  • db.system - always "redis"
  • db.operation.name - the Redis command name (e.g. "GET", "SET")
  • db.statement - the full command with arguments sanitized
  • db.redis.database_index - database index if present in metadata
  • server.address - Redis server host if present
  • server.port - Redis server port if present

Teardown

Redis.OpenTelemetry.detach()

Summary

Functions

Attaches telemetry handlers that create OpenTelemetry spans for Redis commands.

Detaches the OpenTelemetry telemetry handlers.

Functions

attach()

@spec attach() :: :ok | {:error, :already_exists}

Attaches telemetry handlers that create OpenTelemetry spans for Redis commands.

detach()

@spec detach() :: :ok | {:error, :not_found}

Detaches the OpenTelemetry telemetry handlers.