Skip to content
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

Add request and response hooks to web framework instrumentations #408

Open
owais opened this issue Apr 5, 2021 · 2 comments
Open

Add request and response hooks to web framework instrumentations #408

owais opened this issue Apr 5, 2021 · 2 comments

Comments

@owais
Copy link
Contributor

owais commented Apr 5, 2021

It'd be really nice for all web server instrumentations to provide request and response hooks so users can customize behavior (update span name, attributes, etc), record additional information from incoming/outgoing requests/responses, allow injecting tracing related data into responses such as trace response headers, etc. This should be implemented for both client and server libraries.

In order to be consistent across all instrumentations, I recommend all instrumentations follow the following guidelines:

  • When possible the hook signatures should satisfy:
request_hook(span: trace.Span, request: RequestObject) -> None

response_hook(span: trace.Span, request: RequestObject, response: ResponseObject): -> None
  • If it is not possible to pass a reference to the request object to the response hook, only span and response should be passed. Instrumentation should not go out of it's way to satisfy the above proposed interface by holding on to request references, etc.
  • The request hook should be called right after the span is created for an incoming/outgoing request.
  • The response hook should be called right before span ends.
@owais
Copy link
Contributor Author

owais commented Apr 5, 2021

@lzchen I see you've created a bunch of issues to span name callbacks. This enables way more features while making it possible to set/update span names as well. Should I update all span name callback issues to implement request/response hooks instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants