How can I add a client interceptor manually? #3241
Unanswered
jenstroeger
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Adding a server interceptor manually is documented here and it seems to work.
Adding a client interceptor manually is not documented, and trying the server pattern fails:
with
as documented here.
Looking through the code, the
client_interceptor()
returns aOpenTelemetryClientInterceptor
instance that inherits from custom OpenTelemetry ABCs — hence the error message.However, there’s also a
opentelemetry.instrumentation.grpc.intercept_channel()
function which I couldn’t find documented but seems to work:Furthermore, considering that the
channel
returned by the custom OpenTelemetryintercept_channel()
is also a context manager (like gRPC’s Channel is), should both be considered, i.e.So my question is: what’s the general recommendation — use the
GrpcInstrumentorServer()
andGrpcInstrumentorClient()
on a module level (better yet, the package’s top-level to ensure instrumentation is installed exactly once), or manual instrumentation? And how does the customintercept_channel()
function work with normal interceptors that don’t inherit from OpenTelementry’s ABCs (I’ve not tried).Cheers!
Beta Was this translation helpful? Give feedback.
All reactions