-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
10.22.0
Framework Version
"node": "18.12.0"
Link to Sentry event
No response
Reproduction Example/SDK Setup
SDK init:
const Sentry = require("@sentry/node");
Sentry.init({
debug:true,
dsn: __MY_DSN__
tracesSampler: samplingContext => {
return 1.0
},
});
A task or script that runs multiple jobs
Sentry.withMonitor("cronespress", () => {
//... cron code
});
// more monitors or any code that runs into an error
try{
throw new Error("Error outside withMonitor")
}catch(e){
Sentry.captureException(e)
}
Sentry.withMonitor("mycronjob-te", () => {
//... cron code
});
Steps to Reproduce
Run the code as above.
Expected Result
Each withMonitor creates its own trace, separated from the current trace and the other crons running
Actual Result
withMonitor does not create a new trace for the cron job.
As a result, the error that happens in one cron, or in between them, will be associated with the check-ins of all crons via the same traceID.
Workarounds are:
- Create a new trace each time with startNewTrace
- Use separate processes, one for each cron.
Additional Context
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
Status
No status