-
-
Notifications
You must be signed in to change notification settings - Fork 154
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 span / transaction collection to sentry-tracing #350
Conversation
Co-authored-by: Arpad Borsos <swatinem@swatinem.de>
ebe32b5
to
15982fc
Compare
Codecov Report
@@ Coverage Diff @@
## master #350 +/- ##
==========================================
+ Coverage 83.08% 83.29% +0.21%
==========================================
Files 62 66 +4
Lines 6478 7206 +728
==========================================
+ Hits 5382 6002 +620
- Misses 1096 1204 +108 |
@leops lgtm I know far too less about both tracing and sentrys own performance/transaction/span APIs. How can I best check this out and run some local tests on it before I merge? |
I guess the tracing library could use some more examples, the basic one for using the tracing feature would look something like this:
Running this should create both a transaction of a few spans for the calls to the |
@leops can you make sure to bump the minimum version of |
…+ expand upon the existing example to include transaction collection as well
Done, and I've also updated the readme to include the example I previously posted |
Please add this to the main crate rustdoc. The readme is actually auto-generated. (I should probably add a comment to these readme files to make that clear) |
Right I updated the crate documentation and ran the script to make sure everything is in place |
sentry-tracing/src/lib.rs
Outdated
//! #[tokio::main] | ||
//! async fn main() { | ||
//! let _guard = sentry::init(sentry::ClientOptions { | ||
//! dsn: "<dsn>".parse().ok(), |
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.
Its okay to have this, but IMO the examples should rather fall back to grabbing SENTRY_DSN
from the env, which they do when this is left as None
/default.
Oh, I guess you need to put tokio into the dev dependencies in order for rustdoc to pick it up. |
I had to turn on a few features for the example to compile (for instance I needed to turn on the multi threaded scheduler because using the single threaded one would require a change to the |
❤️ Thank you so much for working on this! |
I'm marking this as a draft for now as it builds upon the changes in #349 to submit Transaction data directly to the Client as an Envelope. I'll rebase this branch on master when that other PR gets sorted out. (Edit: PR got merged, I rebased my branch)
Anyway for the actual changes: this builds upon the existing
sentry-tracing
infrastructure, a new filter and 3 mappers to the crate. First isspan_filter
, it is used to select spans that are candidate for transaction collection, thenspan_mapper
is called for all spans that pass the filter to create aprotocol::Span
. This Span is expected to only be partially initialized as thetracing::Span
has only been newly created when the mapper is called, and more informations can be added by mutating the protocol struct when the tracing Span gets closed inspan_on_close
. Finally, either the closing span can be attached to another span that passed the filter higher up in the hierarchy, or if no parent can be found the span is turned into a full transaction bytransaction_mapper
and submitted (This last part could be further improved by either adding atransaction_filter
or having thespan_filter
return an enum to select which Spans are allowed to be submitted as Transactions).For the last part, besides the previously mentioned changes to
sentry-types
I has to implement thetraces_sample_rate
config options as well as a newsample_traces_should_send
method on the Client (unlikesample_should_send
this one is public so that it can be called from another crate).