-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(opentelemetry): Stop looking at propagation context for span creation #14481
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,17 +34,55 @@ test('Sends an API route transaction to OTLP', async ({ baseURL }) => { | |
const scopeSpans = json.resourceSpans?.[0]?.scopeSpans; | ||
expect(scopeSpans).toBeDefined(); | ||
|
||
// Http server span & undici client spans are emitted | ||
// Http server span & undici client spans are emitted, | ||
// as well as the spans emitted via `Sentry.startSpan()` | ||
// But our default node-fetch spans are not emitted | ||
expect(scopeSpans.length).toEqual(2); | ||
expect(scopeSpans.length).toEqual(3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was also incorrect before, spans from |
||
|
||
const httpScopes = scopeSpans?.filter(scopeSpan => scopeSpan.scope.name === '@opentelemetry/instrumentation-http'); | ||
const undiciScopes = scopeSpans?.filter( | ||
scopeSpan => scopeSpan.scope.name === '@opentelemetry/instrumentation-undici', | ||
); | ||
const startSpanScopes = scopeSpans?.filter(scopeSpan => scopeSpan.scope.name === '@sentry/node'); | ||
|
||
expect(httpScopes.length).toBe(1); | ||
|
||
expect(startSpanScopes.length).toBe(1); | ||
expect(startSpanScopes[0].spans.length).toBe(2); | ||
expect(startSpanScopes[0].spans).toEqual([ | ||
{ | ||
traceId: expect.any(String), | ||
spanId: expect.any(String), | ||
parentSpanId: expect.any(String), | ||
name: 'test-span', | ||
kind: 1, | ||
startTimeUnixNano: expect.any(String), | ||
endTimeUnixNano: expect.any(String), | ||
attributes: [], | ||
droppedAttributesCount: 0, | ||
events: [], | ||
droppedEventsCount: 0, | ||
status: { code: 0 }, | ||
links: [], | ||
droppedLinksCount: 0, | ||
}, | ||
{ | ||
traceId: expect.any(String), | ||
spanId: expect.any(String), | ||
name: 'test-transaction', | ||
kind: 1, | ||
startTimeUnixNano: expect.any(String), | ||
endTimeUnixNano: expect.any(String), | ||
attributes: [{ key: 'sentry.op', value: { stringValue: 'e2e-test' } }], | ||
droppedAttributesCount: 0, | ||
events: [], | ||
droppedEventsCount: 0, | ||
status: { code: 0 }, | ||
links: [], | ||
droppedLinksCount: 0, | ||
}, | ||
]); | ||
|
||
// Undici spans are emitted correctly | ||
expect(undiciScopes.length).toBe(1); | ||
expect(undiciScopes[0].spans.length).toBe(1); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,6 @@ describe('awsIntegration', () => { | |
}); | ||
|
||
test('should auto-instrument aws-sdk v2 package.', done => { | ||
createRunner(__dirname, 'scenario.js').expect({ transaction: EXPECTED_TRANSCATION }).start(done); | ||
createRunner(__dirname, 'scenario.js').ignore('event').expect({ transaction: EXPECTED_TRANSCATION }).start(done); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unrelated, but saw this flaking every now and then so decided to just ignore events here. |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# How Trace Propagation Works in the JavaScript SDKs | ||
|
||
Trace propagation describes how and when traceId & spanId are set and send for various types of events. | ||
How this behaves varies a bit from Browser to Node SDKs. | ||
|
||
## Node SDKs (OpenTelemetry based) | ||
|
||
In the Node SDK and related OpenTelemetry-based SDKs, trace propagation works as follows: | ||
|
||
![node-sdk-trace-propagation-scenarios](./assets/node-sdk-trace-propagation.png) | ||
|
||
## Browser/Other SDKs | ||
|
||
TODO |
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.
I do not really know why this was not here before, but IMHO it was incorrect? These errors (same for the other nest E2E tests), as you'll usually have the http.server span and then inside it some e.g. route handler span or so, so the active span at the time of the error should usually have a parent_span_id. So I'd say this fixes incorrect (?) behavior 🤔