-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Update httpIntegration
handling of incoming requests
#17371
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
base: develop
Are you sure you want to change the base?
Conversation
size-limit report 📦
|
8d7f49c
to
e798a09
Compare
e798a09
to
57f8184
Compare
const runner = createRunner(__dirname, 'server.js') | ||
.expect({ | ||
transaction: { | ||
transaction: 'GET /test/:id/span-updateName-source', | ||
transaction: 'new-name', |
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.
this is actually... fixed here now? Not quite sure why/how, but apparently some timing stuff is better now?
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.
this indicates that the retroactive span name extraction is no longer use. Which makes sense to me if we now set a good name right from the start!
(I think this is fine btw. Actually leaves less room for user error in case they don't use the Sentry.updateSpanName
helper)
2f90c3c
to
c120396
Compare
a280e0c
to
7b052e3
Compare
status: 'ok', | ||
}, | ||
}, | ||
describe('custom server.emit', () => { |
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.
these tests have been added to verify that everything still works even if a user (or some other library) also wraps server.emit
. This was the case in the nestjs-distributed-tracing E2E test.
8a65711
to
d9e8b1f
Compare
span.end(); | ||
|
||
// Update the transaction name if the route has changed | ||
if (newAttributes['http.route']) { |
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.
Since we control this now, we can actually do this in a generalized way instead of doing this per-framework, I think most if not all of them (e.g. express etc.) use this mechanism to set the route, so we could eventually remove the per-integration code for this in many places, I believe (and we'll also automatically support other frameworks in the future). cc @Lms24
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.
nice!
// This fails https://github.com/getsentry/sentry-javascript/pull/12587#issuecomment-2181019422 | ||
// Skipping this for now so we don't block releases | ||
test.skip('Should record spans from http instrumentation', async ({ request }) => { | ||
test('Should record spans from http instrumentation', async ({ request }) => { |
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.
not sure if this is fixed by this specifically or something else, but this seems to work again now.
a6259bf
to
434adfe
Compare
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.
Nice! Looking forward to basic tracing without always depending on OTel. Had some minor remarks but looks ready to me otherwise!
@@ -224,7 +224,7 @@ module.exports = [ | |||
import: createImport('init'), | |||
ignore: [...builtinModules, ...nodePrefixedBuiltinModules], | |||
gzip: true, | |||
limit: '116 KB', | |||
limit: '51 KB', |
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 guess we just forgot to adjust this? Would be pretty sweet otherwise xD
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 just counted this wrongly 😅
const runner = createRunner(__dirname, 'server.js') | ||
.expect({ | ||
transaction: { | ||
transaction: 'GET /test/:id/span-updateName-source', | ||
transaction: 'new-name', |
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.
this indicates that the retroactive span name extraction is no longer use. Which makes sense to me if we now set a good name right from the start!
(I think this is fine btw. Actually leaves less room for user error in case they don't use the Sentry.updateSpanName
helper)
span.end(); | ||
|
||
// Update the transaction name if the route has changed | ||
if (newAttributes['http.route']) { |
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.
nice!
Extracted out of #17371 I noticed that we were not fully consistent in instrumentation IDs for integrations that have multiple instrumentation. The intent is that users can provide the _integration name_ (e.g. `Http`) and it will preload all http instrumentation. To achieve this, I adjusted the preload filter code to look for exact matches as well as `startsWith(`${name}.id`)`. I also adjusted the test to be more declarative and mock/reset stuff properly (this lead to issues in the linked PR, and should generally be a bit cleaner). I also updated all instrumentation IDs to follow this pattern. We should be mindful of following this with new instrumentation we add.
78679a0
to
b8613b0
Compare
Co-authored-by: Lukas Stracke <[email protected]>
b8613b0
to
ce6aaa1
Compare
This PR updates the handling of the Node SDK of incoming requests. Instead of relying on @opentelemetry/instrumentation-http for this, we now handle this internally, ensuring that we can optimize performance as much as possible and avoid interop problems. This will also allow us to extract this out of an OTEL instrumentation, eventually paving the way for a non-OTEL SDK with basic tracing capabilities.
This change should not affect users, unless they are relying on very in-depth implementation details. Importantly, this also drops the
_experimentalConfig
option of the integration - this will no longer do anything.Finally, you can still pass
instrumentation.{requestHook,responseHook,applyCustomAttributesOnSpan}
options, but they are deprecated and will be removed in v11. Instead, you can use the newincomingRequestSpanHook
configuration option if you want to adjust the incoming request span.I have tried to ensure the spans look as similar as possible as before, this should be reflected in the tests.