-
-
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
Event processors are not executed on cloned Scopes #5575
Comments
const Sentry = require('@sentry/node')
const {Scope} = require('@sentry/node')
Sentry.init({
dsn: '*insert dsn*',
beforeSend(event) {
console.log(event.tags)
return event
},
})
const scope = Scope.clone(Sentry.getCurrentHub().getScope())
scope.setTag('scope', 1)
scope.addEventProcessor(function(event, hint) {
console.log('event processor 1')
event.tags.eventProcessor1 = 1
return event
})
Sentry.withScope((scope2) => {
scope2.addEventProcessor(function(event, hint) {
console.log('event processor 2')
event.tags.eventProcessor2 = 2
return event
})
scope2.setTag('scope2', 2)
Sentry.captureException(new Error('test'), scope)
}) This code yields:
Tags from |
Hi @Loskir, thanks for writing in! This doesn't work because when you call If you take a look at the link, you'll see that this method internally calls the client's Would you mind telling me what you would like to achieve with adding this event processor? Also, is the example you provided below (with calling |
I want to create a new scope each time a request arrives at the server and then add some request-specific info to it. I thought that by configuring the scope and then passing it to captureException it would work the same way as when using The main concern here is to prevent data leaks from one request to the other. I don't use I'd like to have a good way of creating some container where I can safely store some request-specific data and then adding that data on |
@Loskir check out us using domains here as an example: https://github.com/getsentry/sentry-javascript/pull/5590/files#diff-754e32c1c14ac3c3c93eedeb7680548b986bc02a8b0bc63d2efc189210322acdR323 |
@Loskir thanks for the context. Yes, in this case, definitely check out domains for that. I hope this helps you. |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/node
SDK Version
7.10.0
Framework Version
No response
Link to Sentry event
No response
Steps to Reproduce
Run this code
Expected Result
EventProcessors are executed
Actual Result
EventProcessors are not executed. No console output
The text was updated successfully, but these errors were encountered: