class GrpcInstrumentation extends AbstractInstrumentation implements GrpcOperationObserver

Constants

protected CLIENT_DURATION_METRIC

protected SERVER_DURATION_METRIC

protected RPC_METHOD_OTHER

protected ATTEMPT_COUNT_ATTRIBUTE

protected DURATION_BOUNDARIES

Properties

protected InstrumentationOptions $options from  AbstractInstrumentation
protected TracerInterface|null $tracer
protected HistogramInterface|null $clientDuration
protected HistogramInterface|null $serverDuration
protected bool $serverMetricAddress

Methods

void
register(array $options)

Register the instrumentation with normalized options.

void
registerInstrumentation()

Register the logical gRPC operation observer 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(GrpcOperationRunner $operations, TracerProviderInterface $tracerProvider, MeterProviderInterface $meterProvider, ClockInterface $clock, TextMapPropagatorInterface $propagator, GrpcMetadataSetter $metadataSetter, LogContextScopeFactory $logContextScopes, ExceptionContextRegistry $exceptionContexts, OperationOrigin $origins, ProcessIdentity $identity)

Create gRPC instrumentation.

mixed
starting(GrpcOperation $operation)

Start observing a logical gRPC operation.

void
finished(GrpcOperation $operation, mixed $token, GrpcOperationResult $result)

Finish observing a logical gRPC operation.

startClient(ClientGrpcOperation $operation)

Start a logical client call.

startServer(ServerGrpcOperation $operation)

Start a logical server call.

void
complete(GrpcOperation $operation, GrpcTelemetryState $state, GrpcOperationResult $result)

Complete one logical gRPC call.

array
sharedAttributes(GrpcOperation $operation)

Return shared logical RPC attributes.

array
clientAttributes(ClientGrpcOperation $operation)

Return logical client-call attributes.

array
serverEndpointAttributes(ServerGrpcOperation $operation)

Return truthful configured server endpoint attributes.

string
method(GrpcOperation $operation)

Return the recognized RPC method or its bounded fallback.

HistogramInterface|null
duration(GrpcOperation $operation)

Return the enabled duration instrument for an operation.

string|null
errorType(GrpcOperation $operation, StatusCode|null $status, string|null $statusName, Throwable|null $exception)

Return the semantic error type for a completed call.

never
unsupportedOperation(GrpcOperation $operation)

Reject a gRPC operation type the instrumentation cannot classify.

string
statusName(StatusCode $status)

Return the standard gRPC status name.

Details

final void register(array $options)

Register the instrumentation with normalized options.

Parameters

array $options

Return Value

void

at line 91
protected void registerInstrumentation()

Register the logical gRPC operation observer 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 74
__construct(GrpcOperationRunner $operations, TracerProviderInterface $tracerProvider, MeterProviderInterface $meterProvider, ClockInterface $clock, TextMapPropagatorInterface $propagator, GrpcMetadataSetter $metadataSetter, LogContextScopeFactory $logContextScopes, ExceptionContextRegistry $exceptionContexts, OperationOrigin $origins, ProcessIdentity $identity)

Create gRPC instrumentation.

Parameters

GrpcOperationRunner $operations
TracerProviderInterface $tracerProvider
MeterProviderInterface $meterProvider
ClockInterface $clock
TextMapPropagatorInterface $propagator
GrpcMetadataSetter $metadataSetter
LogContextScopeFactory $logContextScopes
ExceptionContextRegistry $exceptionContexts
OperationOrigin $origins
ProcessIdentity $identity

at line 128
mixed starting(GrpcOperation $operation)

Start observing a logical gRPC operation.

Parameters

GrpcOperation $operation

Return Value

mixed

at line 144
void finished(GrpcOperation $operation, mixed $token, GrpcOperationResult $result)

Finish observing a logical gRPC operation.

Parameters

GrpcOperation $operation
mixed $token
GrpcOperationResult $result

Return Value

void

at line 161
protected GrpcTelemetryState startClient(ClientGrpcOperation $operation)

Start a logical client call.

Parameters

ClientGrpcOperation $operation

Return Value

GrpcTelemetryState

at line 213
protected GrpcTelemetryState startServer(ServerGrpcOperation $operation)

Start a logical server call.

Parameters

ServerGrpcOperation $operation

Return Value

GrpcTelemetryState

at line 268
protected void complete(GrpcOperation $operation, GrpcTelemetryState $state, GrpcOperationResult $result)

Complete one logical gRPC call.

Parameters

GrpcOperation $operation
GrpcTelemetryState $state
GrpcOperationResult $result

Return Value

void

at line 341
protected array sharedAttributes(GrpcOperation $operation)

Return shared logical RPC attributes.

Parameters

GrpcOperation $operation

Return Value

array

at line 354
protected array clientAttributes(ClientGrpcOperation $operation)

Return logical client-call attributes.

Parameters

ClientGrpcOperation $operation

Return Value

array

at line 367
protected array serverEndpointAttributes(ServerGrpcOperation $operation)

Return truthful configured server endpoint attributes.

Parameters

ServerGrpcOperation $operation

Return Value

array

at line 381
protected string method(GrpcOperation $operation)

Return the recognized RPC method or its bounded fallback.

Parameters

GrpcOperation $operation

Return Value

string

at line 393
protected HistogramInterface|null duration(GrpcOperation $operation)

Return the enabled duration instrument for an operation.

Parameters

GrpcOperation $operation

Return Value

HistogramInterface|null

at line 405
protected string|null errorType(GrpcOperation $operation, StatusCode|null $status, string|null $statusName, Throwable|null $exception)

Return the semantic error type for a completed call.

Parameters

GrpcOperation $operation
StatusCode|null $status
string|null $statusName
Throwable|null $exception

Return Value

string|null

at line 436
protected never unsupportedOperation(GrpcOperation $operation)

Reject a gRPC operation type the instrumentation cannot classify.

Parameters

GrpcOperation $operation

Return Value

never

at line 447
protected string statusName(StatusCode $status)

Return the standard gRPC status name.

Parameters

StatusCode $status

Return Value

string