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
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.
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
10.22.0
Framework Version
"node": "18.12.0"
Link to Sentry event
No response
Reproduction Example/SDK Setup
SDK init:
A task or script that runs multiple jobs
Steps to Reproduce
Run the code as above.
Expected Result
Each
withMonitorcreates its own trace, separated from the current trace and the other crons runningActual Result
withMonitordoes 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:
Additional Context
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it.