-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
@sentry/node does not include user data in Transactions #15044
Comments
Hi, can you share the exact code with which you assign a user to the scope? Thanks! |
Please also note that we don't build (or support) |
@lforst |
Sorry for some reason I completely missed that. Instead of doing |
Thank you for fast response, your solution seems to work, I will test it further on environment with many users. Still, it's very confusing that the user which is set on scope is ignored even though the scope gets passed to the transaction. And isn't SentrySDK a global scope? |
I am gonna go ahead and assume The global |
Just expanding a bit on what @lforst already wrote: In the example, you are not using Generally, I think the problem you are running into is that the scope you pass in is not used directly, but will be forked. So only changes made to the scope before it is passed to scope.setTag('before', '1');
Sentry.startSpan({ name: 'span', scope }, () => {
scope.setTag('after', '2');
// ... do something
// if you really want to do that, do:
Sentry.getCurrentScope().setTag('after2', '2');
});
// the `span` will only have the `before` tag, not the `after` tag The same applies to user and anything else put on the scope. You cannot mutate this scope afterwards. Why would you even need to manually create scopes and pass them around? All of this should be handled for you by You should never rely on the scope being something specific somewhere, as this may be forked and changed under the hood at any time. Always use |
Thank you both for explanation. It's clear now this needs to be solved in rlanz/sentry and there is no issue in @sentry/node. |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.50.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
https://github.com/RomainLanz/sentry/blob/v0.2.0/src/middleware.ts
Steps to Reproduce
I am using AdonisJS v6 framework with the Sentry integration rlanz/sentry v0.2.0.
It works well, except for one single issue.
On the Performance Back-end dashboard, I see no count of Users and no value for User Misery.
First I thought there is some issue with setting the user on the scope after starting the span as you can see in the section Assigning User Context. But even if I call setUser directly on the scope before the startSpan function is called with the scope passed to it as a parameter, as you can see in the reproduction example, the user is still never sent in the data of the transaction. When error happens on the scope and the exception is captured, the user is there and I expected the same will apply to the transactions.
Expected Result
User will be included in Transaction event data and Performance dashboard will show count of Users and User Misery value.
Actual Result
User is not included in Transaction event data and Performance dashboard shows count of Users as 0 and no value for User Misery.
The text was updated successfully, but these errors were encountered: