-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
trace grpc http requests via net/http/httptrace #6589
Comments
We currently don't expose TLS handshakes or DNS messages as trace events or via interceptors. There are some plans to make more data available via traces and metrics as part of our observability project, but we are not sure at this point whether what you are asking will be exposed. Could you please tell us your usecase? Also, if this (dns resolution events and tls handshakes) is something really important to you, you could implement your own custom credentials that wraps the TLS credentials implementation provided by gRPC and make some metrics available to your application. Similarly you can create your own custom resolver that wraps the DNS resolver and makes metrics available to you. But this is not something we would recommend without completely understanding your usecase. |
My use case is very simple. I have 50+ services and all works fine. But sometimes some services get timeouts. Dashboards from k8s does not have problems dns works fine, packet loss absent and so. I'm enable tracing in my services and see that some requests get stuck - one service call grpc endpoint , other service receives request and sent response. But half of all spent time is black hole - i'm lost something somewhere. |
@easwars ? |
I'm try to pass own ContextDialer to get span from context and measure time. |
gRPC uses some types from the |
Maybe if you show us some code, we might be able to help better. Thanks. |
the example is very easy type myxxx struct{} i'm always get FAIL |
The dialer passed to WithContextDialer is invoked every time a connection to a backend is being established. FYI, when your application creates a To be clear, that context that you pass to your grpc method call is not the same context that is passed to the custom dialer. |
Yes i saw in code, but don't understand why context passed to call not propogated to ContextDialer. |
@easwars so, what the next steps? I can't propogate span to resolver and context dialer does not have context with my span (why??) |
I think if you can pass context from grpc call to ContextDialer this can open many useful features like tracing connection establishment/reconnect detection in tracing, additional logging via injected logger and many other features. Also i think that this is very small change to code base and easy accepted by grpc authors... |
Name resolution is something that is started when the At RPC time, the LB policy decides which of those backends to use to service that RPC call. There is no control flow between things happening at RPC time, and the name resolver. So, there is no way to forward the context passed to the RPC call to the name resolver. That just simply does not make sense.
No, I don't think it will be a small change that will be easily accepted by the maintainers. |
We have a stats handler that uses OpenCensus, that recordes a trace with the time the picker picked: #6422. This constructs a trace with annotations at the timestamp when the rpc was started, and the picker has successfully picked. This is not technically as granular/specific as the time of "dns resolving and tls handshake", but I think that within that timeframe can tell you if it's an rpc taking a long time or the steps up to the picker picking, which encapsulates those two events you want described. To echo Easwar's point, RPC comes after Dialing, so you can't pass an RPC context into Dial as described. |
Also, taking the timestamps of the logs of dns resolver would help here. |
This issue is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
thank you for help |
I need to trace grpc calls not only via interceptors, but understand how much time i spent on dns resolving and tls handshake. In plain http i can use net/http/httptrace to provide hooks.
How can i do something like this in go-grpc?
The text was updated successfully, but these errors were encountered: