-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: add minitrace-futures
to support instrumentation for futures
#202
Conversation
Signed-off-by: iGxnon <[email protected]>
Pull Request Test Coverage Report for Build 7814940816
💛 - Coveralls |
How should I fill in the |
I've a question about the |
Perhaps replace
Can let mut drain = sink::drain().enter_on_poll(|| {
let span = Span::enter_with_parent("SubTask" &root);
// Set the local parent so that `LocalSpan`
// becomes available in the sink.
(span.set_local_parent(), span)
}); or let mut drain = sink::drain().enter_on_poll(|| Span::enter_with_parent("SubTask" &root)); |
This seems too complicated, and maybe we could break it down. Perhaps a |
OK, let's confirm the approximate API first.
It can be done with: let s = stream! {
for i in 0..2 {
yield i;
}
}
.enter_on_item(|| Span::root("Root", SpanContext::random())); In my scenario, I want to create a span for the user from the end of the last request to the receipt of the next request data. I hope this span can also collect some log events from the codec layer (the span needs to be the local parent), and it is best to report them as early as possible (the span is a root span). And I found that the duration of this span can be used to calculate a user's request frequency. At last the span can serve as the parent span for the next root span, allowing users to trace from the socket layer to the application logic processing layer. However, in fact, what I would prefer to do is to calculate the time consumed by the codec layer. It seems difficult to achieve without modifying the Item types of Stream and Sink. If I want to fully customize the lifetime of the span, then need to change the type of the Item in Stream and Sink to the following: enum Item<T> {
StartSpan,
EndSpan,
Item(T),
} The instrumentation layer opens a span upon receiving
For some simple streams or sinks, such as a snapshot stream that closes after complete reception, we can use |
let s = stream! {
for i in 0..2 {
yield i;
}
}
.enter_on_item(|| Span::root("Root", SpanContext::random())); I mean, instead of a flexible but error-prone
Maybe you can do it by implementing https://docs.rs/tokio-util/latest/tokio_util/codec/trait.Decoder.html? Edit: with #204, maybe no need for creating root span here. |
|
Signed-off-by: iGxnon <[email protected]>
Thanks! This is indeed very helpful.
OK, I have pruned this pull request to only include the instrumentation for |
There is another question: is |
I believe it will prove valuable if we can precisely define the semantics of enter_on_item (specifically, determining the precise moment that is considered as enter_on_item) and also develop a concrete example or use case to illustrate its application. |
@iGxnon Thank you! |
Changes:
minitrace-futures
Instrumented
in_span
instrumentation.Checklist:
futures
0.3.xfutures
0.1.x