Skip to content

fix(core): Stop clobbering existing transaction name with scope value #5825

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

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Sep 27, 2022

Draft until we figure out if this is actually what we want to do.


This prevents the transaction name stored on the scope from overwriting an event's existing transaction value. Since the code in question runs before either event processors or beforeSend, the only way for an event to already have a transaction value at that point are

a) to be a transaction, or
b) to be a custom event captured by the user.

In the case of a), we don't want to overwrite the existing transaction value because we've just done a bunch of work to make sure that it's a good, parameterized value coming in. In the case of b), the user has actively provided a name, which we should respect.

Resolves #5660

@github-actions
Copy link
Contributor

github-actions bot commented Sep 27, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.47 KB (+0.03% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 60.24 KB (+0.03% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.09 KB (-0.01% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 53.17 KB (+0.03% 🔺)
@sentry/browser - Webpack (gzipped + minified) 19.85 KB (+0.03% 🔺)
@sentry/browser - Webpack (minified) 64.51 KB (+0.03% 🔺)
@sentry/react - Webpack (gzipped + minified) 19.88 KB (+0.03% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.78 KB (+0.01% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.92 KB (+0.03% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.36 KB (+0.01% 🔺)

@lobsterkatie lobsterkatie force-pushed the kmclb-stop-clobbering-transaction-for-transaction-events branch from 1e5bbcb to 9ed4512 Compare September 27, 2022 04:25
@lobsterkatie lobsterkatie requested a review from lforst September 27, 2022 06:42
@@ -465,7 +465,7 @@ export class Scope implements ScopeInterface {
event.level = this._level;
}
if (this._transactionName) {
event.transaction = this._transactionName;
event.transaction = event.transaction || this._transactionName;
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a comment here on why we did this? I.e. a one- or two-liner saying that we don't want to set event.transaction for transaction events and that it works because transaction events have a transaction field set from the get-go.

@lforst
Copy link
Member

lforst commented Sep 27, 2022

Shouldn't this resolve #5660 (as opposed to resolving only a part of it)?

@lobsterkatie
Copy link
Member Author

Shouldn't this resolve #5660 (as opposed to resolving only a part of it)?

My take was that there's still an open question of what setTransactionName should actually do. (Like, should it actually set the name of the transaction (assuming there's an active one on the scope)? Can we in fact get away with removing it in JS (even if not across the board in all SDKs)? etc)

@lobsterkatie lobsterkatie force-pushed the kmclb-stop-clobbering-transaction-for-transaction-events branch from 9ed4512 to 2bb1bcf Compare September 27, 2022 07:49
@lforst
Copy link
Member

lforst commented Sep 27, 2022

Shouldn't this resolve #5660 (as opposed to resolving only a part of it)?

My take was that there's still an open question of what setTransactionName should actually do. (Like, should it actually set the name of the transaction (assuming there's an active one on the scope)? Can we in fact get away with removing it in JS (even if not across the board in all SDKs)? etc)

Ah I guess that's also problematic. I originally opened the issue in the context of dynamic sampling where it simply messed up transaction names + source, which is fixed by this PR. So I would just close that issue and open up a new one that basically says "Scope.setTransactionName is confusing" and we discuss how to proceed with the API. Okay for you?

@lobsterkatie
Copy link
Member Author

So I would just close that issue and open up a new one that basically says "Scope.setTransactionName is confusing" and we discuss how to proceed with the API. Okay for you?

I'm fine with that, but I think you could easily get away with not opening a new issue and just commenting on #5718.

@AbhiPrasad
Copy link
Member

Can we add a test showing we’ll set a transaction name if it’s not defined?

@vladanpaunovic vladanpaunovic linked an issue Sep 27, 2022 that may be closed by this pull request
@lobsterkatie
Copy link
Member Author

Pausing on this because I couldn't quite bring myself to write "this makes scope.setTransactionName no longer set the name of the transaction on the scope" in the changelog, because that makes no sense as an improvement. Before proceeding, we're going to try to gather data on how often this is being used in the wild. Moving this to draft so it doesn't get merged in the meantime.

@lobsterkatie lobsterkatie marked this pull request as draft September 30, 2022 02:32
@AbhiPrasad AbhiPrasad closed this Jan 30, 2023
@AbhiPrasad AbhiPrasad deleted the kmclb-stop-clobbering-transaction-for-transaction-events branch January 30, 2023 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problematic API: Scope.setTransactionName()
3 participants