grzegorzdrozd / otel-auto-redis
OpenTelemetry auto-instrumentation for Redis
Requires
- php: ^8.2
- ext-opentelemetry: *
- colinmollenhour/credis: ^1.16
- guzzlehttp/guzzle: ^7.9
- guzzlehttp/psr7: ^2.7
- open-telemetry/api: ^1.0
- open-telemetry/exporter-otlp: ^1.2
- open-telemetry/sem-conv: ^1.24
- symfony/cache: ^7.2
- symfony/polyfill-mbstring: ^1.31
Requires (Dev)
- ext-redis: *
- friendsofphp/php-cs-fixer: ^3
- open-telemetry/sdk: ^1.0
- phan/phan: ^5.0
- php-http/mock-client: *
- phpredis/phpredis: ^6.1
- phpstan/phpstan: ^1.1
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- predis/predis: ^2.3
- psalm/plugin-phpunit: ^0.18.4
- vimeo/psalm: ^5.0
Suggests
This package is auto-updated.
Last update: 2025-03-15 20:59:42 UTC
README
Please read https://opentelemetry.io/docs/instrumentation/php/automatic/ for instructions on how to install and configure the extension and SDK.
Overview
Auto-instrumentation hooks are registered via Composer, and spans will automatically be created for
selected redis
operations (by default: all Redis commands).
Configuration
You can disable the extension using runtime configuration:
OTEL_PHP_DISABLED_INSTRUMENTATIONS=redis OTEL_PHP_DISABLED_INSTRUMENTATIONS=predis OTEL_PHP_DISABLED_INSTRUMENTATIONS=credis
Module specific configuration
Disable instrumentation for specific commands
You can disable instrumentation for specific commands. This can be useful if you have some commands that are executed very often and you don't want to create spans for them. This option is disabled by default. Use environment variables to set this option. You can set multiple commands separated by a comma. You can also specify "group" of commands using @<group_name>. Groups are defined in the src/CommandGroupEnum.php
file. List of commands and groups can be found in the src/AbstractInstrumentation.php
file. You can define commands individually for each supported extension.
OTEL_PHP_INSTRUMENTATION_REDIS_PREDIS_FUNCTIONS=@all,-@readonly OTEL_PHP_INSTRUMENTATION_REDIS_CREDIS_FUNCTIONS=@write OTEL_PHP_INSTRUMENTATION_REDIS_REDIS_FUNCTIONS=get,mget
Tracking connection details for clustered connection
In Predis you can configure a clustered connection (for replication, sharding, etc.). In this case, there is no clear way to see which server executed a command. Changing this setting to true will use Predis methods to get information about which connection executed the command. Optionally, when cluster mode is set to redis, it will make a second call to Redis to determine this information. This will make your code slower. This option is disabled by default.
OTEL_PHP_INSTRUMENTATION_PREDIS_TRACK_AGGREGATED_CONNECTIONS=true