Activate request Transaction as current span#87
Conversation
86d1977 to
be2c6b6
Compare
|
@intgr let me know when you had some time to review it |
|
I am terribly sorry, I have procrastinated about this PR.
But my gut feeling is that we're not doing something right with Sentry APIs, and that's why it's not working using the approach documented by upstream. The proposed solution seems more like a work-around. We should If doing it the "upstream way" doesn't work, we should understand it better, before implementing this approach. I suspect what's going wrong right now is that we're creating a Transaction, but we're not telling Sentry "this is the current active transaction". But I haven't looked yet in detail. |
|
Thank you for your reply. |
b284bd3 to
2eb9324
Compare
|
The trick was simply to use I cleaned the PR to have only relevant commits. I also recycled the |
intgr
left a comment
There was a problem hiding this comment.
Thanks! looks good to me.
Ooooops, this took over half a year. 😅
| Self::start_transaction(name) | ||
| let transaction = sentry::start_transaction(transaction_context); | ||
| Hub::current().configure_scope(|scope| { | ||
| scope.set_span(Some(transaction.clone().into())); |
There was a problem hiding this comment.
For a moment I thought that we could use scope.get_span() later to retrieve the transaction & avoid needing to clone/local_cache_once!()
But it's probably a bad idea, as the user might override the span. We should still finish the original one.
|
Released as v1.0.0 https://github.com/intgr/rocket-sentry/releases/tag/v1.0.0 |
|
Wonderful! |

Hi, I am looking to add some details on what's taking time in a request.
I looked at the documentation and examples provided by sentry:
But for some reasons it doesn't works with the transaction created in this crate. My attempt is here.
So I propose to expose the created transaction using a Rocket guard.
The result of

performance_with_customs_spans:get_current_transactionis what's really needed,SentryGuardandwrap_in_spanare just for ease of use. We can also decide to keepget_current_transactionprivate and only exposeSentryGuard...