tbachert / otel-instrumentation-amphp-http-client
OpenTelemetry amphp/http-client instrumentation
Installs: 34
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/tbachert/otel-instrumentation-amphp-http-client
Requires
- php: ^8.2
- composer-runtime-api: ^2.0
- amphp/http-client: ^5.0
- league/uri: ^7.0
- open-telemetry/api: ^1.8
- open-telemetry/context: ^1.1
- open-telemetry/opentelemetry-config-http: ^0.1
Requires (Dev)
- amphp/http-server: ^3.3
- amphp/phpunit-util: ^3.0
- phpunit/phpunit: ^9.6
- tbachert/otel-sdk: ^0.1
This package is auto-updated.
Last update: 2026-02-15 10:41:37 UTC
README
Installation
composer require tbachert/otel-instrumentation-amphp-http-client
Usage
Automatic instrumentation
This instrumentation is enabled by default.
Disable via file-based configuration
instrumentations/development: php: amphp_http_client: false
Disable via env-based configuration
OTEL_PHP_DISABLED_INSTRUMENTATIONS=amphp-http-client
Manual instrumentation
use Amp\Http\Client\HttpClientBuilder; use Nevay\OTelInstrumentation\AmphpHttpClient\EventListener\Logs; use Nevay\OTelInstrumentation\AmphpHttpClient\EventListener\Metrics; use Nevay\OTelInstrumentation\AmphpHttpClient\EventListener\RequestPropagator; use Nevay\OTelInstrumentation\AmphpHttpClient\EventListener\Tracing; $httpClient = (new HttpClientBuilder) ->listen(new Tracing($tracerProvider)) ->listen(new Metrics($meterProvider)) ->listen(new Logs($loggerProvider)) ->listen(new RequestPropagator($propagator)) ->build(); $response = $httpClient->request(...);
Accessing the client span of a request
use OpenTelemetry\API\Trace\SpanInterface; $span = $response->getRequest()->getAttribute(SpanInterface::class);