otel_grpc 0.2.0 copy "otel_grpc: ^0.2.0" to clipboard
otel_grpc: ^0.2.0 copied to clipboard

OpenTelemetry instrumentation for `package:grpc`. Client and server interceptors emitting rpc.* spans, propagating W3C trace context via gRPC metadata, with recursion suppression.

Changelog #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

0.2.0 - 2026-08-10 #

Added #

  • OTelGrpcClientInterceptorClientInterceptor subclass that wraps every unary and streaming RPC in a CLIENT-kind span, injects W3C trace context into the call metadata, and maps gRPC status codes to OTel span status. Sets the registry-current RPC semconv attributes: rpc.system.name=grpc, fully-qualified rpc.method, rpc.response.status_code (canonical status name, e.g. OK / NOT_FOUND). Optional serverAddress / serverPort constructor parameters emit server.address / server.port (interceptors can't see the ClientChannel, so the values are caller-supplied — never fabricated).
  • OTelGrpcServerInterceptor — class-based ServerInterceptor (grpc >= 4.1.0) for Server.create(serverInterceptors: ...). The span wraps the whole handler invocation and ends when the response stream completes or errors, so durations and status codes are real (an earlier draft used the function-typedef hook, which fires before the call and cannot observe completion). Extracts W3C trace context from ServiceCall.clientMetadata so server spans parent into the calling trace.
  • grpcStatusCodeName — canonical gRPC status names for the rpc.response.status_code values; unknown codes emit the numeric code as a string.
  • runWithoutGrpcInstrumentation / runWithoutGrpcInstrumentationAsync — zone-scoped suppression helpers. The interceptors check a zone flag and skip span creation entirely, breaking the recursion hazard when an OTLP/gRPC export call would otherwise pass back through the interceptor.
  • 8 unit tests against a real in-process gRPC Server on an ephemeral port: client happy path, traceparent injection, GrpcError → Error status, suppression, parent-span inheritance; server real-duration span, GrpcError mapping, W3C extraction.

Changed #

  • Semantic conventions updated to the current OTel registry: registry-deprecated keys are no longer emitted — rpc.systemrpc.system.name, rpc.service → folded into a fully-qualified rpc.method, and the numeric rpc.grpc.status_code → the string rpc.response.status_code. The local GrpcSemantics enum is gone with them.
  • Dependency floors raised to dartastic_opentelemetry ^1.1.0-beta.12 and dartastic_opentelemetry_api ^1.0.0-rc.1. The previous floors declared compatibility with API versions that predate the semconv enums this package uses and could not actually resolve-and-compile.
  • repository URL corrected to the canonical Dartastic org casing so pub.dev repository verification succeeds.

Known limitations #

  • Server-side rpc.method is unqualified: package:grpc's ServiceMethod doesn't carry a back-reference to its parent Service. The client emits the fully-qualified form.
0
likes
160
points
71
downloads

Documentation

API reference

Publisher

verified publisherdartastic.io

Weekly Downloads

OpenTelemetry instrumentation for `package:grpc`. Client and server interceptors emitting rpc.* spans, propagating W3C trace context via gRPC metadata, with recursion suppression.

Homepage
Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dartastic_opentelemetry, dartastic_opentelemetry_api, grpc

More

Packages that depend on otel_grpc