Skip to content

Commit 560c6a3

Browse files
committed
add integration-level option
1 parent 46f6503 commit 560c6a3

File tree

2 files changed

+25
-16
lines changed
  • dev-packages/node-integration-tests/suites/express/tracing
  • packages/node/src/integrations/http

2 files changed

+25
-16
lines changed

dev-packages/node-integration-tests/suites/express/tracing/test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -248,23 +248,23 @@ describe('express tracing', () => {
248248

249249
test('correctly ignores request data', async () => {
250250
const runner = createRunner(__dirname, 'server.js')
251-
.expect({
252-
transaction: (e) => {
253-
assertSentryTransaction(e, {
254-
transaction: 'POST /test-post-ignore-body',
255-
request: {
256-
url: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post-ignore-body$/),
257-
method: 'POST',
258-
headers: {
259-
'user-agent': expect.stringContaining(''),
260-
'content-type': 'application/octet-stream',
251+
.expect({
252+
transaction: e => {
253+
assertSentryTransaction(e, {
254+
transaction: 'POST /test-post-ignore-body',
255+
request: {
256+
url: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post-ignore-body$/),
257+
method: 'POST',
258+
headers: {
259+
'user-agent': expect.stringContaining(''),
260+
'content-type': 'application/octet-stream',
261+
},
261262
},
262-
},
263-
});
264-
// Ensure the request body has been ignored
265-
expect(e).have.property('request').that.does.not.have.property('data');
266-
},
267-
})
263+
});
264+
// Ensure the request body has been ignored
265+
expect(e).have.property('request').that.does.not.have.property('data');
266+
},
267+
})
268268
.start();
269269

270270
runner.makeRequest('post', '/test-post-ignore-body', {

packages/node/src/integrations/http/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ interface HttpOptions {
7373
*/
7474
ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;
7575

76+
/**
77+
* Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.
78+
* This can be useful for long running requests where the body is not needed and we want to avoid capturing it.
79+
*
80+
* @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.
81+
* @param request Contains the {@type RequestOptions} object used to make the outgoing request.
82+
*/
83+
ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;
84+
7685
/**
7786
* If true, do not generate spans for incoming requests at all.
7887
* This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.

0 commit comments

Comments
 (0)