SentryGrpcInterceptor class
A gRPC ClientInterceptor that adds Sentry instrumentation to outgoing RPC calls.
For each unary call, the interceptor:
- Creates a child span under the active transaction (legacy) or active span (span-first).
- Injects
sentry-traceandbaggageheaders into the call metadata for distributed tracing. - Records a breadcrumb with the method path, status, and duration.
- Optionally captures failed RPCs (non-OK status codes or transport errors) as Sentry exceptions.
Server-streaming calls receive header injection only; full span lifecycle tracking for streaming RPCs will be added in a future release.
final channel = ClientChannel('api.example.com');
final interceptor = SentryGrpcInterceptor();
final stub = GreeterClient(channel, interceptors: [interceptor]);
To capture failed RPCs (overriding SentryOptions.captureFailedRequests):
final interceptor = SentryGrpcInterceptor(captureFailedRequests: true);
- Annotations
-
- @experimental
Constructors
- SentryGrpcInterceptor({Hub? hub, bool? captureFailedRequests, bool enableBreadcrumbs = true})
- Creates a SentryGrpcInterceptor.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
interceptStreaming<
Q, R> (ClientMethod< Q, R> method, Stream<Q> requests, CallOptions options, ClientStreamingInvoker<Q, R> invoker) → ResponseStream<R> -
interceptUnary<
Q, R> (ClientMethod< Q, R> method, Q request, CallOptions options, ClientUnaryInvoker<Q, R> invoker) → ResponseFuture<R> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- integrationName → const String
- Integration name registered with the Sentry SDK.