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

dev-main / 0.1.x-dev 2026-02-15 10:40 UTC

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);