-
Notifications
You must be signed in to change notification settings - Fork 169
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
[tracing] Allow to customize TracingLayer based on request #330
Conversation
Hello, Gentle bump regarding this PR :) |
I'm sorry but please don't "bump" PRs, especially after just a week. Everyone who works on tower-http are volunteers so we'll get to it when we get to it. |
Hello @davidpdrsn, No worries and sorry about that. It wasn't to be unrespectful of your time, as I wasn't knowing, it was to be sure the PR haven't been missed. Now that I know, I am fine with the wait. Thank you for your time. |
Hi back, I hope you are going well. I think this PR can provide values to others, internally we use it to provide metrics/trace per request { path and status } on several projects, and I am sure it can benefit others too. So my question is, how can I help to move this forward. |
The main problem here is the amount of time maintainers can put into the project in their free time (since nobody is paid to work on this). I can think of one way you can help and that is to provide reviews of other PRs¹ so that once somebody with merge access reviews, there is a higher chance that it is already in a mergable state and they can move on to something else. ¹ there is one other PR that hasn't received a review yet: #333 |
I haven't had time to think about the consequences of doing this change. tower-http's tracing stuff is already complicated enough as is, so I'm not sure if we wanna add more stuff to it. Could be, not sure 🤷 |
I just had a look at what's actually being proposed here and have to say I'm not a fan. This isn't just about the change itself though, I had previously only used To try to explain what I'm not feeling happy about: The API to me seems like it is over-using generics and traits. I think the obvious counter-example to this is |
Hehe yes it's entirely possible that I went too much into the generics on this one 😅 The main difference tracing and cors though is that tracing has lots of callbacks. We could use more |
Thank you for the responses :)
Sure, whatever my expertise on the matter is worth, I will take time to review it Thursday morning
Yeah, I agree the implementation is complex, at least the type signature is scary. Regarding the PR, the code only introduces into each callback trait an "adapter" that must know the request type, which is generic over its body. So basically most of the code is some glue to forward the type of the Body into every single callbacks type, and as there is one trait for each ¯\(ツ)/¯ |
I can try to make something simpler if you are OK with breaking changes. Regarding the consequence of this change, I am biased, but I don't see further evolution required in the future. |
Hello,
This is a rough/draft patch aiming to provide support for starting a discussion.
Motivation
TracingLayer is a great place to hook itself to gather information about the lifecycle of every request.
Sadly each trait OnRequest, OnResponse, OnFailure, OnEos, ... are independent of each others, and it is not possible to pass information between them.
In some cases, it is desirable to pass request information to other layers.
Take for example the case where we want to provide metrics regarding each request response's status per path
or for example, how to count the number of in-flight request per path ?
At the moment, the only context that is passed around is the span, but it is difficult to use it to attach information.
Span id, have no guarantee around uniqueness, so cannot be used as an index.
Span.record() let attach information, but it is not possible to retrieve the value attached to it.
Solution
This patch aims to support this use case by adding on each layer/Onxxx an
adapt
method where is passed the initial Request and the span (not sure the span is necessary), to allow them to know the context of the execution and adapt themselves to it.For example, for in the previous example:
or for example counting the number of in-flight requests, would look like:
Discuss
The discussion I would like to start, is do you think this approach is the right one ?
If yes, would you be interested in a more complete patch for it to be integrated.