-
-
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
Changes from all commits
85e8c5e
1f1d7e5
c7c57a6
a01483b
bb5a9d3
79f7c71
390d3a2
5702fef
c508c61
da629f6
0837198
6c01021
338d17c
ed04cae
d8e7a54
af4e876
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 |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I just counted this wrongly 😅 |
||
}, | ||
// Node SDK (ESM) | ||
{ | ||
|
@@ -233,14 +233,14 @@ module.exports = [ | |
import: createImport('init'), | ||
ignore: [...builtinModules, ...nodePrefixedBuiltinModules], | ||
gzip: true, | ||
limit: '150 KB', | ||
limit: '152 KB', | ||
}, | ||
{ | ||
name: '@sentry/node - without tracing', | ||
path: 'packages/node/build/esm/index.js', | ||
import: createImport('initWithoutDefaultIntegrations', 'getDefaultIntegrationsWithoutPerformance'), | ||
gzip: true, | ||
limit: '110 KB', | ||
limit: '95 KB', | ||
ignore: [...builtinModules, ...nodePrefixedBuiltinModules], | ||
modifyWebpackConfig: function (config) { | ||
const webpack = require('webpack'); | ||
|
@@ -263,7 +263,7 @@ module.exports = [ | |
import: createImport('init'), | ||
ignore: [...builtinModules, ...nodePrefixedBuiltinModules], | ||
gzip: true, | ||
limit: '135 KB', | ||
limit: '107 KB', | ||
}, | ||
]; | ||
|
||
|
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 }) => { | ||
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', | ||
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? 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); | ||
}; | ||
} | ||
} |