tbachert/otel-instrumentation-amphp-http-client

OpenTelemetry amphp/http-client instrumentation

dev-main / 0.1.x-dev 2024-10-15 21:16 UTC

This package is auto-updated.

Last update: 2024-12-15 21:51:17 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);