feat!: remove Extra members from spans and transactions - #5589
jamescrosswell wants to merge 1 commit into
Conversation
ISpanData and IEventLike no longer inherit IHasExtra. Scope and SentryEvent implement it directly. Scope.Apply copies scope extras into Data for transactions, preserving previous behaviour. Closes #4640 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## version7 #5589 +/- ##
===========================================
Coverage ? 74.80%
===========================================
Files ? 515
Lines ? 18913
Branches ? 3698
===========================================
Hits ? 14147
Misses ? 3887
Partials ? 879 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
This is a bit ugly... note the two separate cases that have to be considered now:
case IHasExtra hasExtracase IHasData hasData
Reason
Spans and transactions: all have IHasData now... including ISpan, ISpanData, ITransactionData, ITransactionTracer, SentrySpan, SentryTransaction, SpanTracer and TransactionTracer... and IEventLike itself has IHasExtra Those types already had IHasData before this change. Their Extra was only an alias that read and wrote the same store as Data, so removing there is trivial.
Scope and SentryEvent: still IHasExtra... no IHasData.
Solutions
Ultimately we should be removing Extras from the Scope and SentryEvent as well. These should be replaced by Scope.Attributes and I assume Event.Attributes but Event.Attributes is nowhere on the horizon so we can't do that yet.
For the time being, this PR simply removes Extra from Spans and Transactions... which I have to say is pretty confusing. It leaves us with multiple disparate APIs:
| Type | Interface |
|---|---|
| Span | IHasData |
| Transaction | IHasData |
| SentryEvent | IHasExtra |
| Scope | IHasExtra |
| Logs | Attributes |
| Metrics | Attributes |
Honestly I think we're better off leaving IHasExtra on the the v1 Spans/Transactios so that at least there's consistency across everything except Logs and Metrics if we do that.
The other option would be to try to migrate SentryEvent and Scope to IHasData... it's kind of throw away work for us, since we'll eventually be deprecating Data as well (in favour of attributes) and it's just annoying churn for our SDK users (we'd be breaking their code twice in two releases, instead of once in one release).
|
Closing for now. See https://github.com/getsentry/sentry-dotnet/pull/5589/changes#r4032951473. We can pick this up once we have Event.Attributes... that way we can move everything to Attributes rather than moving piecemeal to Data and then throwing all that away and moving to attributes. |
Warning
Don't merge - need to work out what to do with Scopes and Events first... interrogating colleagues to try to work this out.
Removes
Extra/SetExtrafromSentrySpan,SentryTransaction,TransactionTracer,SpanTracer(andNoOpSpan). These were aliases over the same store asData.To get there,
ISpanDataandIEventLikeno longer inheritIHasExtra, which also drops it fromISpan,ITransactionDataandITransactionTracer. Internal callers (HTTP/GraphQL handlers, ASP.NET Core middleware, EF/SQL listeners, OpenTelemetry span processor) now useData/SetData.Open questions for review
ScopeandSentryEventstill implementIHasExtra(now declared directly), with noData. An event'sextrais a separate protocol field from span/tracedata, and it was never marked obsolete, so this PR leaves it alone. The result is a bit lopsided:IEventLikeno longer exposes extras at all. Worth deciding whether that's the shape we want for v7, or whether this should wait for Attributes (as the issue suggests) and land with an analyzer/code fix.Scope.Apply(IEventLike)now type-switches:IHasExtratargets get extras as before,IHasDatatargets (transactions) get them asData. That preserves today's behaviour of scope extras ending up in trace data, but it's the ugliest part of the change. Dropping theIHasDatabranch would stop scope extras reaching transactions.Closes #4640
🤖 Generated with Claude Code