feat: Send transactions as Span v2 streams#4912
Conversation
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Features ✨
Dependencies ⬆️Deps
Other
🤖 This preview updates automatically when you update the PR. |
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- Send transactions as Span v2 streams ([#4912](https://github.com/getsentry/sentry-dotnet/pull/4912))If none of the above apply, you can opt out of this check by adding |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4912 +/- ##
==========================================
+ Coverage 73.88% 76.84% +2.96%
==========================================
Files 494 406 -88
Lines 17868 15156 -2712
Branches 3509 3025 -484
==========================================
- Hits 13202 11647 -1555
+ Misses 3807 2791 -1016
+ Partials 859 718 -141 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
@Flash0ver just a heads up, I needed Attributes for the span streaming stuff so extracted this functionality out from the SentryMetrics class... just in case you might change any of this in another PR.
Yes to both.
In Python, we store the sampled flag outside of attributes as a standalone property on the span object. It doesn't make sense to store it as an attribute IMO since there's no value in sending it over the wire (since it'd always be
I believe not since the protocol doesn't take them into account, @cleptric?
Would these fit? If at least partially, we can extend them and add to our conventions.
I'd suggest to add it under
Does OTel have anything for this? If yes, we should follow that (and add it to our conventions). If not, we should come up with something new (and add it to our conventions).
Correct, V2 spans start with status
In general, for SDK-set tags/data, these should, if possible, be matched to corresponding attributes from the Sentry or OTel conventions. We shouldn't attempt to auto-translate user-set tags/data to attributes; the |
Partially implements #4790:
Specifically it implements the first three steps of the Implementation Guidelines:
Converting classic/static transactions and spans to the SpanV2 format
To implement step 3, we have to be able to convert
SentryTransactionandSentrySpantypes toSpanV2types so that these can be sent using the new streaming protocol, so we need to work out how to map the properties of these slightly different shapes to one another.Some of these properties can be mapped to the base properties of the SpanV2 payload. Others have to be mapped to attributes, using the semantic conventions. We're mapping the properties of the Span Interface as follows:
Name
Classic spans just have a Description, so it seems logical to map Description to SpanV2.Name there.
Classic Transactions have both a
Nameand aDescription.It lookes like the
Transaction.Nameshould probably map tosentry.segment.namesince a Transaction in the old terminology is roughly equivalent to a Segment in the streaming protocol.So for the span representing the Segment, should that also use
Transaction.Nameas the SpanV2.Name?IsSampled
The
IsSampledproperty of the classic span can be mapped to thesentry.dsc.sampledattribute, which is a boolean that indicates whether the span was sampled or not. I'm not sure if this is what other SDKs are doing.Platform
The
Platformproperty doesn't really have a natural home in the semantic convetions. It's alwayscsharp. I guess we put this in a new custom attribute calledsentry.platform? Would be good to align with other SDKs on this.Distribution
Again, for distribution, the best I can find is to make up a new custom attribute called
sentry.distribution. Should we do this?Breadcrumbs
Will SpanV2 envelopes includ breadcrumbs?
Contexts
App
No idea what to do with the App context.
Runtime
Some of the fields from the runtime fit nicely in
process.runtime.*. Build is about the only one that doesn't fit.Gpu
No idea what to do with this. Custom attributes???
Status
Static spans/transactions allow for a multitude of quite specific Status codes. Streaming spans have just two:
OkandError... so we obviously have to flatten this information.Note
Possibly the specific error code could be preserved in an attribute???
Tags and Data
The static protocol allows for Tags and Data properties that store additional arbitraty information. The most obvious place to map these is to attributes.
It should be noted that it is possible to have collisions between the keys used for tags and data (for example if the SDK user has stored both a tag and a piece of data using the same key). It's also possible for collisions between the keys used for tags/data and the keys from our semantic conventions.
Note
Possibly we could prefix tags/data with
tag.anddata.to avoid collisions???