class HttpClientInstrumentation extends AbstractInstrumentation

Traits

LogsMessagesTrait

Constants

protected DURATION_BOUNDARIES

protected REDIRECT_COUNT_OPTION

protected URL_TEMPLATE

Properties

protected InstrumentationOptions $options from  AbstractInstrumentation
protected array<string, true> $knownMethods
protected bool $manual
protected TracerInterface|null $tracer
protected HistogramInterface|null $duration
protected HttpTelemetryAttributes $httpAttributes

Methods

void
register(array $options)

Register the instrumentation with normalized options.

void
registerInstrumentation()

Register HTTP client middleware and instruments.

bool
tracesEnabled()

Determine whether trace output is enabled.

bool
metricEnabled(string $name)

Determine whether a metric is enabled.

bool
isDirectCancellation(Throwable|null $exception)

Determine whether the throwable is a direct coroutine cancellation.

string
schemaUrl()

Return the semantic conventions schema URL for Hypervel instrumentation scopes.

array
indexObservers(array $names, array $observers)

Index callback observers by their matching instrument name.

__construct(Factory $factory, TracerProviderInterface $tracerProvider, MeterProviderInterface $meterProvider, TextMapPropagatorInterface $propagator, PsrRequestHeadersSetter $requestSetter, ClockInterface $clock, OpenTelemetryManager $manager, ExceptionContextRegistry $exceptionContexts, OperationOrigin $origins, ProcessIdentity $identity)

Create HTTP client instrumentation.

middleware()

Return the physical-send middleware.

bool
shouldTrace(array $options)

Determine whether this request should create a client span.

array
methodAttributes(RequestInterface $request)

Return the method attributes for a physical request.

array
requestAttributes(RequestInterface $request, array $methodAttributes)

Return attributes shared by the span and duration metric.

array
requestTraceAttributes(RequestInterface $request, array $methodAttributes, array $options)

Return recording-only request attributes.

void
applyUrlTemplate(SpanInterface $span, RequestInterface $request, array $methodAttributes)

Apply an application-provided URL template to a recording span.

void
completeResponse(ResponseInterface $response, SpanInterface|null $span, ContextInterface $context, int $startedAt, array $requestAttributes)

Complete a successful physical request.

void
completeFailure(Throwable $exception, SpanInterface|null $span, ContextInterface $context, int $startedAt, array $requestAttributes)

Complete a failed or canceled physical request.

void
complete(SpanInterface|null $span, ContextInterface $context, int $startedAt, array $attributes)

Record the duration and end the client span.

int|null
effectivePort(UriInterface $uri)

Return the effective HTTP port.

Details

final void register(array $options)

Register the instrumentation with normalized options.

Parameters

array $options

Return Value

void

at line 101
protected void registerInstrumentation()

Register HTTP client middleware and instruments.

Return Value

void

protected bool tracesEnabled()

Determine whether trace output is enabled.

Return Value

bool

protected bool metricEnabled(string $name)

Determine whether a metric is enabled.

Parameters

string $name

Return Value

bool

protected bool isDirectCancellation(Throwable|null $exception)

Determine whether the throwable is a direct coroutine cancellation.

Ending an operation by direct cancellation is control flow, not a failure.

Parameters

Throwable|null $exception

Return Value

bool

protected string schemaUrl()

Return the semantic conventions schema URL for Hypervel instrumentation scopes.

Every tracer, meter and logger obtained for one scope must pass the same URL.

Return Value

string

protected array indexObservers(array $names, array $observers)

Index callback observers by their matching instrument name.

The SDK supplies observers in the same order as the instruments passed to batchObserve(), so the unchanged name order is the mapping contract.

Parameters

array $names
array $observers

Return Value

array

at line 84
__construct(Factory $factory, TracerProviderInterface $tracerProvider, MeterProviderInterface $meterProvider, TextMapPropagatorInterface $propagator, PsrRequestHeadersSetter $requestSetter, ClockInterface $clock, OpenTelemetryManager $manager, ExceptionContextRegistry $exceptionContexts, OperationOrigin $origins, ProcessIdentity $identity)

Create HTTP client instrumentation.

Parameters

Factory $factory
TracerProviderInterface $tracerProvider
MeterProviderInterface $meterProvider
TextMapPropagatorInterface $propagator
PsrRequestHeadersSetter $requestSetter
ClockInterface $clock
OpenTelemetryManager $manager
ExceptionContextRegistry $exceptionContexts
OperationOrigin $origins
ProcessIdentity $identity

at line 145
protected Closure middleware()

Return the physical-send middleware.

Return Value

Closure

at line 262
protected bool shouldTrace(array $options)

Determine whether this request should create a client span.

Parameters

array $options

Return Value

bool

at line 272
protected array methodAttributes(RequestInterface $request)

Return the method attributes for a physical request.

Parameters

RequestInterface $request

Return Value

array

at line 295
protected array requestAttributes(RequestInterface $request, array $methodAttributes)

Return attributes shared by the span and duration metric.

Parameters

RequestInterface $request
array $methodAttributes

Return Value

array

at line 312
protected array requestTraceAttributes(RequestInterface $request, array $methodAttributes, array $options)

Return recording-only request attributes.

Parameters

RequestInterface $request
array $methodAttributes
array $options

Return Value

array

at line 340
protected void applyUrlTemplate(SpanInterface $span, RequestInterface $request, array $methodAttributes)

Apply an application-provided URL template to a recording span.

Parameters

SpanInterface $span
RequestInterface $request
array $methodAttributes

Return Value

void

at line 383
protected void completeResponse(ResponseInterface $response, SpanInterface|null $span, ContextInterface $context, int $startedAt, array $requestAttributes)

Complete a successful physical request.

Parameters

ResponseInterface $response
SpanInterface|null $span
ContextInterface $context
int $startedAt
array $requestAttributes

Return Value

void

at line 422
protected void completeFailure(Throwable $exception, SpanInterface|null $span, ContextInterface $context, int $startedAt, array $requestAttributes)

Complete a failed or canceled physical request.

Parameters

Throwable $exception
SpanInterface|null $span
ContextInterface $context
int $startedAt
array $requestAttributes

Return Value

void

at line 463
protected void complete(SpanInterface|null $span, ContextInterface $context, int $startedAt, array $attributes)

Record the duration and end the client span.

Parameters

SpanInterface|null $span
ContextInterface $context
int $startedAt
array $attributes

Return Value

void

at line 482
protected int|null effectivePort(UriInterface $uri)

Return the effective HTTP port.

Parameters

UriInterface $uri

Return Value

int|null