feat(node-experimental): Keep breadcrumbs on transaction #8967
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements an experimental way to handle breadcrumbs for the POTEL world.
This patches stuff so that we get the breadcrumbs from the root transaction, instead of from the scope. This is how it works:
Scope.addBreadcrumb()
to fetch the current transaction, and if there is one, add breadcrumbs thereScope.getBreadcrumbs()
to fetch breadcrumbs from current transaction (if there is one)Proxy
to allow to store breadcrumbs on them._prepareEvent
on the experimental node Client to ensurecaptureContext
worksHow does that work with breadcrumbs in practice
This means that for each isolated request (=that creates its own transaction), we'll keep the breadcrumbs in there. So anything that happens inside of this branch will get all breadcrumbs from this transaction.
This works well 98% of the time, in my testing. For most scenarios, this resulted in the most correct (subjectively speaking) breadcrumbs for both transactions as well as errors.
Note that one scenario where this may not work as expected is with parallel
withScope()
calls, e.g.:In this scenario,
parallel error 2
will also showconsole.log(scope1-...)
.For me, this is an acceptable case for now.
On the other hand, here are some cases where it works as expected:
Overall, I think it works much better than the status quo of the POTEL-backed version.
TODO: What if no transactions?
With the current implementation, this means that if you do not enable tracing, you'll get "incorrect" breadcrumbs again (=the old behavior).
We actually always initialize OTEL (even if tracing is not enabled), but we do not setup any default performance integrations, thus do not generate any transactions by default etc. Probably OK for now (=it will still kind of work, but not great), something to think about later.