-
Notifications
You must be signed in to change notification settings - Fork 254
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
[PLAT-12224] Add setTraceCorrelation method to event #2159
Conversation
d23564f
to
e49ba2a
Compare
@@ -420,4 +420,13 @@ describe('@bugsnag/core/event', () => { | |||
})) | |||
}) | |||
}) | |||
|
|||
describe('event.setTraceCorrelation()', () => { | |||
it('allows setting the span and trace id', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a couple of scenarios missing tests:
- if
spanId
isundefined
ornull
it's still added - if
traceId
isundefined
ornull
it's not added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also update the api for setTraceCorrelation
to accept undefined | null
for the spanId?
public setTraceCorrelation(traceId: string, spanId?: string | null): void
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could they both be expected to be null? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could they both be expected to be null? 🤔
Presumably we shouldn't call setTraceCorrelation
if there's no trace ID so I think only span ID should be optional in the API
I don't think it makes sense for span ID to be null
as an expected value (i.e. in the TS type definition) but it's javascript so it can easily end up that way at runtime
so I think the signature should be:
setTraceCorrelation(traceId: string, spanId?: string): void
but in the method we can't assume they have the right types
Goal
Facilitate trace correlation with the performance client
Design
Add new method to events to enable adding span and trace id's, which can be leveraged by
bugsnag-js-performance
to correlate traces and errors, but can also be called manually if requiredChangeset
Add a new
setTraceCorrelation
method to eventsTesting
Add unit test that calls setTraceCorrelation and verifies the span and trace id are present in the serialised event