class HttpClientInstrumentation extends AbstractInstrumentation

Traits

LogsMessagesTrait

Constants

protected DURATION_BOUNDARIES

protected TRACE_OPTION

protected REDIRECT_COUNT_OPTION

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.

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.

void
registerTraceMacros()

Register per-request trace controls.

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 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 102
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 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 85
__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 150
protected void registerTraceMacros()

Register per-request trace controls.

Return Value

void

at line 171
protected Closure middleware()

Return the physical-send middleware.

Return Value

Closure

at line 291
protected bool shouldTrace(array $options)

Determine whether this request should create a client span.

Parameters

array $options

Return Value

bool

at line 301
protected array methodAttributes(RequestInterface $request)

Return the method attributes for a physical request.

Parameters

RequestInterface $request

Return Value

array

at line 324
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 341
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 369
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 410
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 449
protected void completeFailure(Throwable $exception, SpanInterface|null $span, ContextInterface $context, int $startedAt, array $requestAttributes)

Complete a failed physical request.

Parameters

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

Return Value

void

at line 483
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 502
protected int|null effectivePort(UriInterface $uri)

Return the effective HTTP port.

Parameters

UriInterface $uri

Return Value

int|null