I have the following code:
console.log('--------------------------------------');
const tx = Sentry.startTransaction({ name: 'index', op: 'index', sampled: true });
Sentry.getCurrentHub().configureScope((scope) => scope.setSpan(tx));
console.log('AAAAA');
const span = tx.startChild({ op: 'child' });
console.log('BBBBB');
const span2 = span.startChild({ op: 'grandkid' });
console.log('CCCCC');
span2.finish();
span.finish();
tx.finish();
console.log('--------------------------------------');
This results in the following trace created:
Why are there no child spans reported?
Why is the console log line with ‘------’ included in the breadcrumbs? That log is created outside the spans, so I expected it to not be included
Thanks!
Hi @catalysm, the missing spans is a bug, I’ve filled Manually sampling transactions result in missing child spans · Issue #3254 · getsentry/sentry-javascript · GitHub and will be merging a fix soon, will be fixed in the next SDK release. Thanks for reporting!
Note that, in the general case, you don’t need to explicitly pass the sampling decision when starting a transaction. The common case is to configure tracesSampleRate
or tracesSampler
when calling Sentry.init
.
Regarding the breadcrumbs, that’s how breadcrumbs are meant to work – they create a trail of activities that happened before an error or transaction. The console.log
entries are there thanks to one of the default integrations.
Thank you for the quick fix and explanation! Much appreciated 