You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sentry.getCurrentScope().setTransactionName(name) not having any effect #14663
I have an node.js express route that has two main branches within it, and the chosen branch to go down is based on what is passed into the incoming request. The two branches are quite different and would benefit from being regarded within Sentry as two different transactions.
I have tried calling the following soon after the code branches, to override the transaction name:
But... I'm not seeing these two transaction names anywhere in my data... in Performance for example I'm just seeing the GET /myRoute transaction but not separate branchA and branchB transactions.
Are you able to reproduce this using the SDK targeted to Sentry SaaS? If on SaaS they don't output the correct result, this issue should be transferred to the JS SDK repository.
@aldy505 if by Sentry SaaS you just mean the hosted version of Sentry rather than self-hosted, then yes... it appears to be the same regardless of whether my transaction data is sent to my hosted dsn or my self-hosted dsn... I don't see my custom transaction names in either place.
Hey @drmrbrewer I transferred this issue to the JS SDK repo.
Unfortunately, this docs page is very misleading and outdated since v8 of the SDK. To keep it short, scope.setTransactionName() has no influence on spans (i.e. what the Sentry performance product is showing). I opened a docs PR today to finally update this page: getsentry/sentry-docs#12091
You can visit this preview link of the updated page for more information. Feel free to leave feedback on the PR as well if you encounter things that are unclear.
EDIT: I (somewhat accidentally) closed this issue. However, I'll keep it closed for now because the docs PR is already up and should get merged soon. Furthermore, the question should be answered.
Hi @Lms24 thanks, that new page makes it all much clearer. It looks like the most relevant method to me, for my most common usecase which is to set the name dynamically while the request is being processed, will be Sentry.updateSpanName():
This is only available from v8.44.0 and latest is v8.43.0 so I guess I need to wait... or is there any way of trying v8.44.0 now?
TypeError: Cannot read properties of undefined (reading 'updateName')
at Module.updateSpanName (file:///usr/src/app/node_modules/@sentry/core/build/esm/utils/spanUtils.js:305:8)
at MonitorHelper.setTransactionName (file:///usr/src/app/nodeserver.js:10517:20)
...
I haven't yet figured out when/why this happens (*), but I had assumed that the suggested method was 'safe' in the sense that it wouldn't throw an exception if maybe rootSpan was somehow undefined?
(*) maybe it's when the rootSpan has completed by the time that the Sentry helper function gets around to calling updateName() on it?
@drmrbrewer which SDK are you using? This generally shouldn't happen. Any chance you could find out which span you passed into updateSpanName? This might help us find out what's going on.
Hmm this is a bit weird because according to our type definitions getRootSpan must always return a Span and must not return undefined. The span ending itself in the meantime shouldn't cause the reference you're holding to it to suddenly become undefined. Even less because your code is sync, so there shouldn't be an interruption.
I'm afraid to debug this properly, we'd need a reproducible example. If you can (and since you said you're still trying to get to the bottom of this, whenever you're ready), it'd be great if you could provide a small sample project (GH repo, Zip, stackblitz whatever). Otherwise, please provide your Sentry setup code, specific SDK version and a small code snippet example how to reproduce the bug. Since I'm ooo for the next days and closed issues don't get tracked, please open a new issue with the information.
Sorry for the trouble and thanks for sticking with me!
Activity
aldy505 commentedon Nov 27, 2024
Are you able to reproduce this using the SDK targeted to Sentry SaaS? If on SaaS they don't output the correct result, this issue should be transferred to the JS SDK repository.
drmrbrewer commentedon Nov 27, 2024
@aldy505 if by Sentry SaaS you just mean the hosted version of Sentry rather than self-hosted, then yes... it appears to be the same regardless of whether my transaction data is sent to my hosted dsn or my self-hosted dsn... I don't see my custom transaction names in either place.
aldy505 commentedon Dec 9, 2024
@bc-sentry @hubertdeng123 Can you guys help transfer this issue over to sentry-javascript? Thanks.
Lms24 commentedon Dec 11, 2024
Hey @drmrbrewer I transferred this issue to the JS SDK repo.
Unfortunately, this docs page is very misleading and outdated since v8 of the SDK. To keep it short,
scope.setTransactionName()has no influence on spans (i.e. what the Sentry performance product is showing). I opened a docs PR today to finally update this page: getsentry/sentry-docs#12091You can visit this preview link of the updated page for more information. Feel free to leave feedback on the PR as well if you encounter things that are unclear.
EDIT: I (somewhat accidentally) closed this issue. However, I'll keep it closed for now because the docs PR is already up and should get merged soon. Furthermore, the question should be answered.
drmrbrewer commentedon Dec 11, 2024
Hi @Lms24 thanks, that new page makes it all much clearer. It looks like the most relevant method to me, for my most common usecase which is to set the name dynamically while the request is being processed, will be
Sentry.updateSpanName():This is only available from
v8.44.0and latest isv8.43.0so I guess I need to wait... or is there any way of tryingv8.44.0now?Lms24 commentedon Dec 12, 2024
Hey @drmrbrewer this is not yet merged unfortunately, so the version in the
Available Sinceparagraph is only a placeholder.You can follow the progress of the PR here: #14291
drmrbrewer commentedon Dec 18, 2024
@Lms24 looks like this PR is making good progress. When do you think it might end up in a new release? I'm keen to try it out!
Thanks!
Lms24 commentedon Dec 18, 2024
We're probably gonna release today. Your comment gave me some extra motivation to do that :)
You can follow the SDK release here: #14777. After the PR is merged it'll be a matter of hours before the SDK packages are released.
Once 8.47.0 is released, we can merge the docs PRs that depend on it.
drmrbrewer commentedon Dec 18, 2024
@Lms24 great, thanks! Appreciate it.
drmrbrewer commentedon Dec 19, 2024
@Lms24 thanks for pushing this through... seems to work a treat!
Lms24 commentedon Dec 19, 2024
Glad to hear it! Docs should all be up to date as well now :)
drmrbrewer commentedon Dec 20, 2024
@Lms24 I am using the suggested way of setting the root span name while the span is active:
But I'm also sometimes seeing:
I haven't yet figured out when/why this happens (*), but I had assumed that the suggested method was 'safe' in the sense that it wouldn't throw an exception if maybe
rootSpanwas somehowundefined?(*) maybe it's when the
rootSpanhas completed by the time that the Sentry helper function gets around to callingupdateName()on it?Lms24 commentedon Dec 20, 2024
@drmrbrewer which SDK are you using? This generally shouldn't happen. Any chance you could find out which span you passed into
updateSpanName? This might help us find out what's going on.drmrbrewer commentedon Dec 20, 2024
@Lms24 I'm using the node.js SDK. By which span, do you mean the span name I'm trying to set?
Lms24 commentedon Dec 23, 2024
Hmm this is a bit weird because according to our type definitions
getRootSpanmust always return aSpanand must not returnundefined. The span ending itself in the meantime shouldn't cause the reference you're holding to it to suddenly becomeundefined. Even less because your code is sync, so there shouldn't be an interruption.I'm afraid to debug this properly, we'd need a reproducible example. If you can (and since you said you're still trying to get to the bottom of this, whenever you're ready), it'd be great if you could provide a small sample project (GH repo, Zip, stackblitz whatever). Otherwise, please provide your Sentry setup code, specific SDK version and a small code snippet example how to reproduce the bug. Since I'm ooo for the next days and closed issues don't get tracked, please open a new issue with the information.
Sorry for the trouble and thanks for sticking with me!