Add hooks for distributed tracing #201
Description
Not sure if it is the correct time to start this topic as there seem to be quite a lot other todos open which are more important. But I think it can't hurt to start a discussion early regarding this but feel free to defer this or move it to a better place.
Is your feature request related to a problem? Please describe.
Support for distributed tracing (e.g. OpenTelemetry, APMs) requires monkey patching at this time. I as thinking about adding hooks in core intended for tools like OpenTelemetry and APMs to get data they need and to inject required data.
Describe the solution you'd like
Monitoring tools like OpenTelemetry, APMs,... use monkey patching since a long time to hook into various libraries to gather the data they need and to inject their tags to link transactions of distributed applications.
I think core could include hooks to provide the data needed by such tools to avoid (or at least reduce) the need of monkey patching.
I think having hooks on HTTP/3 is most likely more important as hooks on Quic.
A fast guess of which hooks would be helpful:
- A static hook to notify about creation of new sockets
- life cycle events on sessions (including topology information like remote address/port/udp4/6,...)
- hooks to record and modify outgoing headers (e.g. to inject a unique tag identifying the transaction)
- hooks to record incoming headers, maybe even modify them to hide tags it from application
- a more advance feature to inject e.g. a JS tag would require to intercept/monitor the data stream returned by a server. For sure such a hook should be installed per stream only (if supported at all)
It's also important to allow these tools to associate their context to the async transactions involved (from high level HTTP/3 protocol point of view). As a http request is mapped to a stream this will most likely work out of the box by using async hooks.
Describe alternatives you've considered
Keep using monkey patching. Ensure that exposed public API allows to capture the needed information if monkey patched.