class GrpcInstrumentation extends AbstractInstrumentation implements GrpcOperationObserver

Constants

protected CLIENT_DURATION_METRIC

protected SERVER_DURATION_METRIC

protected RPC_SYSTEM_ATTRIBUTE

protected RPC_METHOD_ATTRIBUTE

protected RPC_STATUS_ATTRIBUTE

protected RPC_SYSTEM_GRPC

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.

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 99
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 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 82
__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 136
mixed starting(GrpcOperation $operation)

Start observing a logical gRPC operation.

Parameters

GrpcOperation $operation

Return Value

mixed

at line 152
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 169
protected GrpcTelemetryState startClient(ClientGrpcOperation $operation)

Start a logical client call.

Parameters

ClientGrpcOperation $operation

Return Value

GrpcTelemetryState

at line 223
protected GrpcTelemetryState startServer(ServerGrpcOperation $operation)

Start a logical server call.

Parameters

ServerGrpcOperation $operation

Return Value

GrpcTelemetryState

at line 278
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 349
protected array sharedAttributes(GrpcOperation $operation)

Return shared logical RPC attributes.

Parameters

GrpcOperation $operation

Return Value

array

at line 362
protected array clientAttributes(ClientGrpcOperation $operation)

Return logical client-call attributes.

Parameters

ClientGrpcOperation $operation

Return Value

array

at line 375
protected array serverEndpointAttributes(ServerGrpcOperation $operation)

Return truthful configured server endpoint attributes.

Parameters

ServerGrpcOperation $operation

Return Value

array

at line 389
protected string method(GrpcOperation $operation)

Return the recognized RPC method or its bounded fallback.

Parameters

GrpcOperation $operation

Return Value

string

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

Return the enabled duration instrument for an operation.

Parameters

GrpcOperation $operation

Return Value

HistogramInterface|null

at line 413
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 444
protected never unsupportedOperation(GrpcOperation $operation)

Reject a gRPC operation type the instrumentation cannot classify.

Parameters

GrpcOperation $operation

Return Value

never

at line 455
protected string statusName(StatusCode $status)

Return the standard gRPC status name.

Parameters

StatusCode $status

Return Value

string