-
Notifications
You must be signed in to change notification settings - Fork 173
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
[Bug Fix] - Incorrect trace caused by use of Span::enter
in asynchronous code
#835
Conversation
let params = Params::new(req.params.map(|params| params.get())); | ||
let name = &req.method; | ||
let id = req.id; | ||
let params = Params::new(req.params.map(|params| params.get())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't params, name & id
be extracted outside the async block?
nice catch and work, looks good |
Thanks for the PR! This does make it clear that it can be quite hard to get tracing right when we need a span to cover multiple await points properly; perhaps we should be using the attribute suggested in the docs on these functions instead ( I also noted that in a couple of cases in the PR we were making an So I'm happy to merge this, but let's consider simplifying the code a bit and using the macro, unless it has some downsides? |
jsonrpsee is emitting incorrect trace because of incorrect use of
Span::enter
in async codeSymtoms:
logs are very spammy as the trace is entering incorrect span
this PR replace the use of
Span::enter
withasync {...}.instrument(span).await
as suggested by the tracing dochttps://docs.rs/tracing/latest/tracing/struct.Span.html#in-asynchronous-code