tbachert / otel-instrumentation-amphp-http-client
OpenTelemetry amphp/http-client instrumentation
dev-main / 0.1.x-dev
2024-10-15 21:16 UTC
Requires
- php: ^8.1
- composer-runtime-api: ^2.0
- amphp/http-client: ^5.0
- open-telemetry/api: ^1.0
- open-telemetry/context: ^1.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: 2024-10-15 21:20:09 UTC
README
Installation
composer require tbachert/otel-instrumentation-amphp-http-client
Usage
use Amp\Http\Client\HttpClientBuilder; use Nevay\OTelInstrumentation\AmphpHttpClient\TracingEventListener; $httpClient = (new HttpClientBuilder) ->listen(new TracingEventListener($tracerProvider, $propagator)) ->build(); $response = $httpClient->request(...);
Accessing the client span of a request
use OpenTelemetry\API\Trace\SpanInterface; $span = $response->getRequest()->getAttribute(SpanInterface::class);