-
Notifications
You must be signed in to change notification settings - Fork 92
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
Sample for implementing opentelemetry tracing #136
Comments
Since So now it is possible to add tracing by using events system. |
I’ve started doing this but I have to use contextvars and associate the listeners whenever I start a server; rather than having it in the config of the library |
Could you possibly provide an example that gets the unary/stream combinations right? |
You can (1) create server instance and attach listeners before (2) starting the server. (1) and (2) can be done in different places. This is almost the same as providing interceptors to other libraries when you create a server:
Can you elaborate? What do you mean by "unary/stream combinations right"? |
You can also implement this using monkey patching approach like this: I don't see any limitations in |
Yes, for example, a stream-req-stream-resp would have to create PRODUCE/CONSUME spans rather than CLIENT/SERVER spans, and if one side closes the connection, there might be spans that might be "associated with" a trace, after the fact rather than being sent from the client during runtime (having an explicit parent). Especially so if you're also creating traces for the lifetimes of objects in your app (e.g. I start a new trace when I start the server). I'm also trying to come to terms with how to manage tracing of python asyncio tasks (again, associated with-type spans?) There's also the matter of reading request data from the metadata of requests (caller started trace, provides a SpanContext to the server); a sample of how that should be done in gRPC would be a nice addition (and I'll get there, but I haven't investigated this path fully yet). As for trailing metadata, I haven't been able to find a good resource on this? I've read in the code-docs that it's what is sent as an "ending" to streams? Or can these be sent multiple times during a request/response interaction? As for the events, I haven't been able to figure out how to capture exceptions using the eventing system? E.g. it's not just about providing a span to the Handler, but also to capture exceptions from it. I've resorted to an explicit It would also be interesting to hear if specifically I'm not much for monkeypatching, coming from statically typed languages... It's often more complex to debug and relies on implementation details rather than API:s. |
Adapted Should be enough to understand how to extract request metadata, exceptions, status etc. This example is just a POC, I still don't understand how
Yes, this is how context propagation in Python works. Everyone under the hood use |
Hi @vmagamedov , is this gist still up to date with the best way of doing tracing? :) For example, isn't this more ideomatic? |
It is definitely not the best way of doing tracing, just a quick proof of concept |
It would be great to be able to trace our gRPC servers and clients using opentelemetry. How would I tie it into this library?
I would like to have each message handler be called in a context (or passed one) that I can create further child spans from and attach logs to.
The text was updated successfully, but these errors were encountered: