Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Emit transaction.data inside contexts.trace.data #3936

Merged
merged 17 commits into from
Feb 12, 2025

Conversation

aritchie
Copy link
Collaborator

@aritchie aritchie commented Feb 3, 2025

Resolves #3873

Removed serialization of "Extras" on SentryTransaction

Unit tests included

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aritchie awesome work getting a PR done on day 1! I wasn't necessarily even expecting you to be able to build the repo without some help/questions.

See comments about the name of the field though - I think the purpose of this PR is to change that from Extra to Data for protocol compatibility with the other SDKs.

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aritchie, couple of comments but Trace.Data is looking good now.

We also need to add Span.Data

Note that there is a bit of an equivalence between SpanTracer and SentrySpan... the SpanTracer class is the concrete implementation of ISpan that is used when traces are active. The SentrySpan class is the (mostly immutable) DTO that is used to serialise span data when sending events to Sentry.

Similarly, there are both TransactionTracer and SentryTransaction classes.

... just in case that wasn't obvious.

@bruno-garcia
Copy link
Member

@AbhiPrasad I believe you know why we're doing this and the expected outcome, right? Could you help with a review?

Also tagged @adinauer as this is quite similar to the Java implementation, maybe you have thoughts?

{
IsSampled = false
};
transaction.Contexts.Trace.SetData("transaction1", "transaction_value");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could stay here but my understanding is that we're "replacing" SetExtra on Transaction (Not on Event) with SetData. But it doesn't serialize on the top level document like extra does, it goes under contexts.trace.data

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original PR redirected SetExtra to Contexts.Trace.Data so this is easy to do. Just not sure what you guys are looking for here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aritchie I think Michi's comment clarifies things. So it looks like this PR is on the right track.

I can't see a way to add SetData methods to Transaction and Span without it being a breaking change though. We can't add members to interfaces, but the performance APIs all use/expose interfaces publicly - e.g. here:

public static ITransactionTracer StartTransaction(string name, string operation)
=> CurrentHub.StartTransaction(name, operation);

What I'd suggest then:

  • We keep the existing SetExtra methods and simply map these under the hood (as is already done in this PR) to the data properties on the protocol.
  • We create another issue for the v6.0.0 milestone to add SetData methods to Transactions/Spans (Transactions might actually be gone by then anyway) and mark the Extra/SetExtra members as obsolete at that point
  • For now, we don't add the [Obsolete] to any of the Extra/SetExtra members

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we simply deprecate setExtra and add setData in the current major version?

Regarding changing where this goes customers may have filtering logic in place, e.g. in beforeSend/beforeSendTransaction. Since for Java the change coincided with us working on a major version (v8), we opted for changing this in a major so customers are more careful when upgrading and don't end up sending PII by accident. Here's the Java PR: getsentry/sentry-java#3735 in case you want to compare something.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we simply deprecate setExtra and add setData in the current major version?

This would be a breaking change... adding a new member to an interface would break any existing classes implementing that interface - and this would involve modifying multiple interfaces (for historical reasons).

I think if it was a real showstopper, we could consider doing it. But in this case, changing the names of those methods from SetExtra to SetData doesn't really change anything except how SDK users use our SDK to add arbitrary data to traces and spans. It doesn't enable delivering any features that we want/need for Sentry. So it feels like a lot of work for very little gain.

I'd rather we do this in the next major release (v6.0) unless there is any compelling reason to do it now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bruno-garcia @jamescrosswell Bruno & I had a discussion about this. Bruno agreed to the proposed workflow.
Technically, it doesn't break the signatures for existing calls. There is a new marker-ish interface to deal with the new methods.

I'm fine with whatever. I just want to put this "pr to bed"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aritchie something we could do, which would not be a breaking change, would be to add a SetData extension method to IHasExtra, which simply called SetExtra.

Eventually in version 6.0 we could make those methods on the class rather than extension methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try that. The issue was how much that interface touched. It meant adding all of those methods to a lot of other classes. Changing IHasExtra truly is a breaking change though because users that do implement it, would have to make updates to their models. In this case, they only have to update their Spans (3 classes at the moment)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an interface method/member... An extension method. It would basically just be an alternate syntax for calling Set Extra (without changes to any interfaces or classes).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They want the collection called Data as well. I can't use an extension for the property.

@bruno-garcia bruno-garcia enabled auto-merge (squash) February 12, 2025 20:28
@bruno-garcia bruno-garcia merged commit 4169cb7 into main Feb 12, 2025
@bruno-garcia bruno-garcia deleted the 3873-transaction_data branch February 12, 2025 20:29
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emit transaction.data inside contexts.trace.data
6 participants