Skip to content

Improve grpc instrumentation examples #3575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def serve():
grpc_client_instrumentor.instrument()

async def run():
with grpc.aio.insecure_channel("localhost:50051") as channel:
async with grpc.aio.insecure_channel("localhost:50051") as channel:

stub = helloworld_pb2_grpc.GreeterStub(channel)
response = await stub.SayHello(helloworld_pb2.HelloRequest(name="YOU"))
Expand All @@ -168,7 +168,7 @@ async def run():

from opentelemetry.instrumentation.grpc import aio_client_interceptors

channel = grpc.aio.insecure_channel("localhost:12345", interceptors=aio_client_interceptors())
async with grpc.aio.insecure_channel("localhost:50051", interceptors=aio_client_interceptors()) as channel:


Usage Aio Server
Expand Down Expand Up @@ -253,6 +253,11 @@ async def serve():

.. code-block::

import grpc
from concurrent import futures
from opentelemetry.instrumentation.grpc import filters
from opentelemetry.instrumentation.grpc import server_interceptor

my_interceptor = server_interceptor(
filter_ = filters.negate(filters.method_name("TestMethod"))
)
Expand Down