-
-
Notifications
You must be signed in to change notification settings - Fork 173
Description
Span management operations seem to be relatively costly, making them unsuited for profiling otherwise fast ~zero-alloc code.
This wouldn't matter much if it was only for sampled transactions, but this is actually for every one of them:
Notably after fetching the current scope:
sentry-rust/sentry-tracing/src/layer.rs
Line 210 in e828ca2
| let parent_sentry_span = sentry_core::configure_scope(|s| s.get_span()); |
There's no way to check whether it will eventually be sampled.
This means that integrations such as that of tracing but also custom integrations (I'm writing one at the moment) can't avoid generating a bunch of Strings, Arcs, serde_json::Value for every Span that the framework may decide to sample, even though the framework already knows that it won't be sampled, e.g.:
sentry-rust/sentry-tracing/src/layer.rs
Lines 218 to 222 in e828ca2
| // Add the data from the original span to the sentry span. | |
| // This comes from typically the `fields` in `tracing::instrument`. | |
| for (key, value) in data { | |
| sentry_span.set_data(key, value); | |
| } |
(Where in most integrations, one could avoid generating a
Value, if the trace won't be sampled.)
It looks like one could benefit of being able to:
- Identify from a
TransactionOrSpanwhether it will be sampled, allowing to not create sub-spans and all their resources unless necessary - When creating new transactions, getting access to the sampling API so that we can know in advance whether the transaction will be sampled, and if not, not allocate e.g.
Stringsto builddescription, that then even get re-allocated inTransactionContext.