open-telemetry / opentelemetry-auto-psr18
OpenTelemetry auto-instrumentation for PSR-18 (HTTP Client).
Package info
github.com/opentelemetry-php/contrib-auto-psr18
pkg:composer/open-telemetry/opentelemetry-auto-psr18
Requires
- php: ^8.1
- ext-opentelemetry: *
- open-telemetry/api: ^1.0
- open-telemetry/sem-conv: ^1.32
- psr/http-client: ^1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- nyholm/psr7: *
- open-telemetry/sdk: ^1.0
- phan/phan: ^5.0
- php-http/mock-client: *
- phpstan/phpstan: ^1.1
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.19.2
- vimeo/psalm: 6.4.0
This package is auto-updated.
Last update: 2026-08-19 11:06:01 UTC
README
This is a read-only subtree split of https://github.com/open-telemetry/opentelemetry-php-contrib.
OpenTelemetry PSR-18 auto-instrumentation
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, which will:
- create spans automatically for each PSR-18 request that is sent
- add a
traceparentheader to the request to facilitate distributed tracing
Configuration
Disabling PSR-18 instrumentation
The extension can be disabled via runtime configuration:
OTEL_PHP_DISABLED_INSTRUMENTATIONS=psr18
Request and response header capturing
PSR-18 auto-instrumentation supports capturing headers from both requests and responses as span attributes. This feature is disabled by default and can be enabled through environment variables or array directives in the php.ini configuration file. Header name matching is case-insensitive.
Environment variables configuration
OTEL_INSTRUMENTATION_HTTP_CLIENT_CAPTURE_REQUEST_HEADERS=host,accept OTEL_INSTRUMENTATION_HTTP_CLIENT_CAPTURE_RESPONSE_HEADERS=content-type,server
The legacy options are still supported but are not recommended as they may be deprecated in a future release:
OTEL_PHP_INSTRUMENTATION_HTTP_REQUEST_HEADERS=host,accept OTEL_PHP_INSTRUMENTATION_HTTP_RESPONSE_HEADERS=content-type,server
php.ini configuration
otel.instrumentation.http.request_headers[]=host otel.instrumentation.http.request_headers[]=accept otel.instrumentation.http.response_headers[]=content-type otel.instrumentation.http.response_headers[]=server