-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node): Ensure correct URL is passed to
ignoreIncomingRequests
c…
…allback (#12929) Fix an oversight in our Node `httpIntegration`. It looks like we assumed that the `request` object being passed to `ignoreIncomingRequestHook` and `ignoreOutgoingRequestHook` was of the same type. However, it's not: - `request` is of type `IncomingMessage` in `ignoreIncomingRequestHook` - `request` is of type `RequestOptions` in `ignoreOutgoingRequestHook` fix the bug by simply taking the request.url property instead and adds integration tests to properly test the two options.
- Loading branch information
Showing
5 changed files
with
153 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...es/node-integration-tests/suites/tracing/httpIntegration/server-ignoreIncomingRequests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { loggingTransport } = require('@sentry-internal/node-integration-tests'); | ||
const Sentry = require('@sentry/node'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
transport: loggingTransport, | ||
|
||
integrations: [ | ||
Sentry.httpIntegration({ | ||
ignoreIncomingRequests: url => { | ||
return url.includes('/liveness'); | ||
}, | ||
}), | ||
], | ||
}); | ||
|
||
// express must be required after Sentry is initialized | ||
const express = require('express'); | ||
const cors = require('cors'); | ||
const { startExpressServerAndSendPortToRunner } = require('@sentry-internal/node-integration-tests'); | ||
|
||
const app = express(); | ||
|
||
app.use(cors()); | ||
|
||
app.get('/test', (_req, res) => { | ||
res.send({ response: 'response 1' }); | ||
}); | ||
|
||
app.get('/liveness', (_req, res) => { | ||
res.send({ response: 'liveness' }); | ||
}); | ||
|
||
Sentry.setupExpressErrorHandler(app); | ||
|
||
startExpressServerAndSendPortToRunner(app); |
42 changes: 42 additions & 0 deletions
42
...es/node-integration-tests/suites/tracing/httpIntegration/server-ignoreOutgoingRequests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const { loggingTransport } = require('@sentry-internal/node-integration-tests'); | ||
const Sentry = require('@sentry/node'); | ||
const http = require('http'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
transport: loggingTransport, | ||
|
||
integrations: [ | ||
Sentry.httpIntegration({ | ||
ignoreOutgoingRequests: url => { | ||
return url.includes('example.com'); | ||
}, | ||
}), | ||
], | ||
}); | ||
|
||
// express must be required after Sentry is initialized | ||
const express = require('express'); | ||
const cors = require('cors'); | ||
const { startExpressServerAndSendPortToRunner } = require('@sentry-internal/node-integration-tests'); | ||
|
||
const app = express(); | ||
|
||
app.use(cors()); | ||
|
||
app.get('/test', (_req, response) => { | ||
http | ||
.request('http://example.com/', res => { | ||
res.on('data', () => {}); | ||
res.on('end', () => { | ||
response.send({ response: 'done' }); | ||
}); | ||
}) | ||
.end(); | ||
}); | ||
|
||
Sentry.setupExpressErrorHandler(app); | ||
|
||
startExpressServerAndSendPortToRunner(app); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters