-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Support improved tracing integration by exposing router / path earlier #3700
Comments
Thanks for your issue! What are you proposing exactly? I don't have enough context to come up with a solution here. Do you want new API from the |
@johanbrandhorst Apologies for not being more clear. To be honest, it's a bit ambiguous because looking at the source code, it's not clear what the best path forward is. What is clear is that whatever it is, it should allow looking up the path pattern (and maybe the gRPC method) from a given HTTP request parameter. Looking through the source code, I think the method would need be on |
Thanks for the added detail. Is |
@johanbrandhorst What I'm looking for is the same information, but at the |
I see. I don't even know how we'd do that tbh. The information around paths lives in the generated files, and they're not used until the handler is called. Perhaps this metadata workaround is the best we can do without significant re-architecting? Let me know if you come up with some solution, I'm still happy to consider it. |
🚀 Feature
I should note that I am trying to integrate the Datadog APM, but I believe this applies to OpenTracing/OpenTelemetry as well.
In trying to integration the Datadog APM, I realized that the the annotated context containing the path pattern is available only after HTTP handlers are called. At a high level, I understand why this is the case, but it complicates adding context to telemetry.
For example, when integrating the Datadog APM, the most straightforward way is to use the WrapHandler function:
The second parameters here is meant to be the resource name. Datadog also offers a WithResourceNamer to dynamically generate the resource name (typically the HTTP method and path pattern). Unfortunately,
WithResourceNamer
works at the handler level and therefore it cannot be used to access the path pattern, just the full URL.When looking at how Datadog integrates with other HTTP libraries, including the standard ServerMux, there is usually some capability to lookup the handler and route based on the request.
Unfortunately,
grpc-gateway
doesn't expose the route matching logic in a way that can be accessed outside ofServeHTTP
, making it very difficult to know the parameterized route at the "wrapping" layer.Ultimately, it would be nice if the route matching logic could be extracted from
ServeHTTP
in a way that it was both fast and re-usable to be able to lookup the route given a request.Workarounds
Yes, I could also use the gRPC client/server integration as the docs suggest. In fact, I also do this. However, telemetry at the HTTP layer is very useful.
As a workaround, I am able to use
runtime.WithMetadata
as recommended here to inject the resource name as a span tag, but it feels a bit hacky and disjointed:The text was updated successfully, but these errors were encountered: