Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
85e8c5e1f1d7e5c7c57a6a01483bbb5a9d379f7c71390d3a25702fefc508c61da629f608371986c01021338d17ced04caed8e7a54af4e876File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -117,9 +117,7 @@ test('Should record a transaction for route with parameters', async ({ request } | ||
| }); | ||
| }); | ||
| // 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 }) => { | ||
MemberAuthor 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. not sure if this is fixed by this specifically or something else, but this seems to work again now. | ||
| const transactionEventPromise = waitForTransaction('node-express-esm-preload', transactionEvent => { | ||
| return transactionEvent.contexts?.trace?.data?.['http.target'] === '/http-req'; | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -29,11 +29,11 @@ describe('express tracing', () => { | ||
| // Also calling `updateName` AND setting a source doesn't change anything - Otel has no concept of source, this is sentry-internal. | ||
| // Therefore, only the source is updated but the name is still overwritten by Otel. | ||
| test("calling `span.updateName` and setting attribute source doesn't update the final name in express but it updates the source", async () => { | ||
| test('calling `span.updateName` and setting attribute source updates the final name in express', async () => { | ||
| const runner = createRunner(__dirname, 'server.js') | ||
| .expect({ | ||
| transaction: { | ||
| transaction: 'GET /test/:id/span-updateName-source', | ||
| transaction: 'new-name', | ||
MemberAuthor 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 is actually... fixed here now? Not quite sure why/how, but apparently some timing stuff is better now? Member 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 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 | ||
| transaction_info: { | ||
| source: 'custom', | ||
| }, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import * as Sentry from '@sentry/node'; | ||
| import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
| Sentry.init({ | ||
| dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
| release: '1.0', | ||
| tracesSampleRate: 1.0, | ||
| transport: loggingTransport, | ||
| // We deliberately disable dedupe here, to make sure we do not double wrap the emit function | ||
| // Otherwise, duplicate spans (that we want to test against) may be dropped by dedupe detection | ||
| integrations: integrations => integrations.filter(integration => integration.name !== 'Dedupe'), | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { sendPortToRunner } from '@sentry-internal/node-integration-tests'; | ||
| import http from 'http'; | ||
| const server = http.createServer(function (request, response) { | ||
| const useProxy = request.url.includes('proxy'); | ||
| const patchOriginalEmit = request.url.includes('original'); | ||
| // Monkey patch it again to ensure it still works later | ||
| // We cover multiple possible scenarios here: | ||
| // 1. Use proxy to overwrite server.emit | ||
| // 2. Use proxy to overwrite server.emit, using initial server.emit | ||
| // 3. Use classic monkey patching to overwrite server.emit | ||
| // 4. Use classic monkey patching to overwrite server.emit, using initial server.emit | ||
| monkeyPatchEmit(server, { useProxy, patchOriginalEmit }); | ||
| response.end('Hello Node.js Server!'); | ||
| }); | ||
| const initialServerEmit = server.emit; | ||
| server.listen(0, () => { | ||
| sendPortToRunner(server.address().port); | ||
| }); | ||
| function monkeyPatchEmit(server, { useProxy = false, patchOriginalEmit = false }) { | ||
| const originalEmit = patchOriginalEmit ? initialServerEmit : server.emit; | ||
| if (useProxy) { | ||
| server.emit = new Proxy(originalEmit, { | ||
| apply(target, thisArg, args) { | ||
| return target.apply(thisArg, args); | ||
| }, | ||
| }); | ||
| } else { | ||
| server.emit = function () { | ||
| return originalEmit.apply(server, arguments); | ||
| }; | ||
| } | ||
| } |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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 😅