GRPC

The gRPC integration instruments all incoming requests and outgoing unary-unary, unary-stream grpc requests using grpcio channels.

Use this integration to start or continue transactions for incoming grpc requests, create spans for outgoing requests, and ensure traces are properly propagated to downstream services.

Install

Install sentry-sdk from PyPI with the grpcio extra.

Copied
pip install --upgrade 'sentry-sdk[grpcio]'

Configure

Add appropriate interceptor to your grpc stub/server:

Server

Copied
from sentry_sdk.integrations.grpc.server import ServerInterceptor
import grpc

server = grpc.server(
    thread_pool=...,
    interceptors=[ServerInterceptor()],
)

Client

Copied
from sentry_sdk.integrations.grpc.client import ClientInterceptor
import grpc

with grpc.insecure_channel("example.com:12345") as channel:
    channel = grpc.intercept_channel(channel, *[ClientInterceptor()])

Supported Versions

  • grpcio: 1.21.1+
  • Python: 3.5+
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").