Skip to content

Commit 9fbbd60

Browse files
authored
ref(node)!: Consolidate httpIntegration options
Public option names now match httpServerIntegration / httpServerSpansIntegration. Nested instrumentation hooks are first-class outgoing hooks instead of a leftover OTEL-era nest. Fixes #22255
1 parent d410f29 commit 9fbbd60

15 files changed

Lines changed: 105 additions & 216 deletions

File tree

‎dev-packages/node-integration-tests/suites/express/tracing/instrument-filterStatusCode.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Sentry.init({
99
transport: loggingTransport,
1010
integrations: [
1111
Sentry.httpIntegration({
12-
dropSpansForIncomingRequestStatusCodes: [499, [300, 399]],
12+
ignoreStatusCodes: [499, [300, 399]],
1313
}),
1414
],
1515
});

‎dev-packages/node-integration-tests/suites/express/tracing/instrument.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Sentry.init({
1111
transport: loggingTransport,
1212
integrations: [
1313
Sentry.httpIntegration({
14-
ignoreIncomingRequestBody: url => {
14+
ignoreRequestBody: url => {
1515
if (url.includes('/test-post-ignore-body')) {
1616
return true;
1717
}

‎dev-packages/node-integration-tests/suites/express/with-http/maxIncomingRequestBodySize/instrument-always.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Sentry.init({
77
release: '1.0',
88
tracesSampleRate: 1.0,
99
transport: loggingTransport,
10-
integrations: [Sentry.httpIntegration({ maxIncomingRequestBodySize: 'always' })],
10+
integrations: [Sentry.httpIntegration({ maxRequestBodySize: 'always' })],
1111
});

‎dev-packages/node-integration-tests/suites/express/with-http/maxIncomingRequestBodySize/instrument-medium.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Sentry.init({
77
release: '1.0',
88
tracesSampleRate: 1.0,
99
transport: loggingTransport,
10-
integrations: [Sentry.httpIntegration({ maxIncomingRequestBodySize: 'medium' })],
10+
integrations: [Sentry.httpIntegration({ maxRequestBodySize: 'medium' })],
1111
});

‎dev-packages/node-integration-tests/suites/express/with-http/maxIncomingRequestBodySize/instrument-none.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Sentry.init({
99
transport: loggingTransport,
1010
integrations: [
1111
Sentry.httpIntegration({
12-
maxIncomingRequestBodySize: 'none',
13-
ignoreIncomingRequestBody: url => url.includes('/ignore-request-body'),
12+
maxRequestBodySize: 'none',
13+
ignoreRequestBody: url => url.includes('/ignore-request-body'),
1414
}),
1515
],
1616
});

‎dev-packages/node-integration-tests/suites/express/with-http/maxIncomingRequestBodySize/instrument-small.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Sentry.init({
88
tracesSampleRate: 1.0,
99
transport: loggingTransport,
1010
dataCollection: { httpBodies: [] },
11-
integrations: [Sentry.httpIntegration({ maxIncomingRequestBodySize: 'small' })],
11+
integrations: [Sentry.httpIntegration({ maxRequestBodySize: 'small' })],
1212
});

‎dev-packages/node-integration-tests/suites/express/with-http/maxIncomingRequestBodySize/test.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const MAX_GENERAL = 1024 * 1024; // 1MB
1212
const MAX_MEDIUM = 10_000;
1313
const MAX_SMALL = 1000;
1414

15-
describe('express with httpIntegration and not defined maxIncomingRequestBodySize', () => {
15+
describe('express with httpIntegration and not defined maxRequestBodySize', () => {
1616
afterAll(() => {
1717
cleanupChildProcesses();
1818
});
@@ -60,7 +60,7 @@ describe('express with httpIntegration and not defined maxIncomingRequestBodySiz
6060
});
6161
});
6262

63-
describe('express with httpIntegration, disabled httpBodies, and explicit maxIncomingRequestBodySize', () => {
63+
describe('express with httpIntegration, disabled httpBodies, and explicit maxRequestBodySize', () => {
6464
afterAll(() => {
6565
cleanupChildProcesses();
6666
});
@@ -88,7 +88,7 @@ describe('express with httpIntegration, disabled httpBodies, and explicit maxInc
8888
});
8989
});
9090

91-
describe('express with httpIntegration and maxIncomingRequestBodySize: "none"', () => {
91+
describe('express with httpIntegration and maxRequestBodySize: "none"', () => {
9292
afterAll(() => {
9393
cleanupChildProcesses();
9494
});
@@ -114,7 +114,7 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "none"',
114114
await runner.completed();
115115
});
116116

117-
test('does not capture any request bodies with "none" setting and "ignoreIncomingRequestBody"', async () => {
117+
test('does not capture any request bodies with "none" setting and "ignoreRequestBody"', async () => {
118118
const runner = createRunner()
119119
.expect({
120120
transaction: {
@@ -149,7 +149,7 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "none"',
149149
});
150150
});
151151

152-
describe('express with httpIntegration and maxIncomingRequestBodySize: "always"', () => {
152+
describe('express with httpIntegration and maxRequestBodySize: "always"', () => {
153153
afterAll(() => {
154154
cleanupChildProcesses();
155155
});
@@ -197,7 +197,7 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "always"'
197197
});
198198
});
199199

200-
describe('express with httpIntegration and maxIncomingRequestBodySize: "small"', () => {
200+
describe('express with httpIntegration and maxRequestBodySize: "small"', () => {
201201
afterAll(() => {
202202
cleanupChildProcesses();
203203
});
@@ -266,7 +266,7 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "small"',
266266
});
267267
});
268268

269-
describe('express with httpIntegration and maxIncomingRequestBodySize: "medium"', () => {
269+
describe('express with httpIntegration and maxRequestBodySize: "medium"', () => {
270270
afterAll(() => {
271271
cleanupChildProcesses();
272272
});

‎dev-packages/node-integration-tests/suites/tracing/httpIntegration/instrument-options.mjs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Sentry.init({
1010

1111
integrations: [
1212
Sentry.httpIntegration({
13-
incomingRequestSpanHook: (span, req, res) => {
14-
span.setAttribute('incomingRequestSpanHook', 'yes');
15-
Sentry.setExtra('incomingRequestSpanHookCalled', {
13+
onSpanCreated: (span, req, res) => {
14+
span.setAttribute('onSpanCreated', 'yes');
15+
Sentry.setExtra('onSpanCreatedCalled', {
1616
reqUrl: req.url,
1717
reqMethod: req.method,
1818
resUrl: res.req.url,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ describe('httpIntegration', () => {
2020
cleanupChildProcesses();
2121
});
2222

23-
describe('instrumentation options', () => {
23+
describe('onSpanCreated option', () => {
2424
createEsmAndCjsTests(__dirname, 'server.mjs', 'instrument-options.mjs', (createRunner, test) => {
25-
test('allows to configure incomingRequestSpanHook', async () => {
25+
test('allows to configure onSpanCreated', async () => {
2626
const runner = createRunner()
2727
.expect({
2828
transaction: {
@@ -33,14 +33,14 @@ describe('httpIntegration', () => {
3333
data: {
3434
'url.full': expect.stringMatching(/\/test$/),
3535
'http.response.status_code': 200,
36-
incomingRequestSpanHook: 'yes',
36+
onSpanCreated: 'yes',
3737
},
3838
op: 'http.server',
3939
status: 'ok',
4040
},
4141
},
4242
extra: expect.objectContaining({
43-
incomingRequestSpanHookCalled: {
43+
onSpanCreatedCalled: {
4444
reqUrl: expect.stringMatching(/\/test$/),
4545
reqMethod: 'GET',
4646
resUrl: expect.stringMatching(/\/test$/),

‎docs/migration/v11-end-state.md‎

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,11 @@ Two consequences to be aware of when upgrading:
520520
- **Issue grouping:** Grouping in Sentry differs for events with and without stack traces, so you may see new issue groups after upgrading.
521521
- **Release health:** Events with a stack trace are counted as errors, so a `captureMessage` call (including messages emitted by `captureConsoleIntegration`) now marks the current session as _errored_. This affects errored-session counts but does **not** mark sessions as crashed, so crash-free session rate is unaffected. If you use `captureMessage` for purely informational output, consider using Sentry Logs instead, which is better suited and does not affect release health.
522522
523-
### Incoming HTTP span hooks moved to `incomingRequestSpanHook`
523+
### Incoming HTTP span hooks moved to `onSpanCreated`
524524
525525
Affected SDKs: `@sentry/node` and dependents.
526526
527-
The deprecated `httpIntegration` / `httpServerSpansIntegration` hooks `instrumentation.requestHook`, `instrumentation.responseHook`, and `instrumentation.applyCustomAttributesOnSpan` no longer run for incoming request spans. Use `incomingRequestSpanHook` (on `httpIntegration`) or `onSpanCreated` (on `httpServerSpansIntegration`) instead:
527+
The deprecated `httpIntegration` / `httpServerSpansIntegration` hooks `instrumentation.requestHook`, `instrumentation.responseHook`, and `instrumentation.applyCustomAttributesOnSpan` no longer run for incoming request spans. Use `onSpanCreated` instead. Outgoing request spans use `outgoingRequestHook`, `outgoingResponseHook`, and `outgoingRequestApplyCustomAttributes`.
528528
529529
```js
530530
// before
@@ -538,14 +538,12 @@ Sentry.httpIntegration({
538538

539539
// after
540540
Sentry.httpIntegration({
541-
incomingRequestSpanHook: (span, req, res) => {
541+
onSpanCreated: (span, req, res) => {
542542
span.setAttribute('custom', true);
543543
},
544544
});
545545
```
546546
547-
`httpIntegration`'s `instrumentation` option is still honored for **outgoing** request spans.
548-
549547
### Deno `node:http` server requests are tracked as sessions
550548
551549
Affected SDKs: `@sentry/deno`.
@@ -951,7 +949,54 @@ The `idleTimeout`, `finalTimeout` and `childSpanTimeout` options of interaction
951949
- (Express) The deprecated `patchExpressModule(options)` signature was removed. Use `patchExpressModule(moduleExports, getOptions)` instead.
952950
- The `@sentry/node-core/light/otlp` entry point was removed, along with its optional `@opentelemetry/exporter-trace-otlp-http` peer dependency. `otlpIntegration` is now exported directly from every server-side SDK, so `Sentry.otlpIntegration()` needs no extra import or install.
953951
- The `otlpIntegration` options `setupOtlpTracesExporter` and `collectorUrl` were removed, and the integration no longer sets up a span exporter, span processor, or tracer provider. Configure your own exporter and point it at `Sentry.getOtlpTracesEndpoint(dsn)`, or at your collector's URL if you route through one. See [Connecting Sentry to your OpenTelemetry traces](#connecting-sentry-to-your-opentelemetry-traces).
954-
- The deprecated `httpServerSpansIntegration` `instrumentation.{requestHook,responseHook,applyCustomAttributesOnSpan}` option was removed. Use `onSpanCreated`, or `httpIntegration({ incomingRequestSpanHook })`, to mutate incoming request spans.
952+
- The deprecated `httpServerSpansIntegration` `instrumentation.{requestHook,responseHook,applyCustomAttributesOnSpan}` option was removed. Use `onSpanCreated` to mutate incoming request spans, or `outgoingRequestHook` / `outgoingResponseHook` / `outgoingRequestApplyCustomAttributes` for outgoing request spans.
953+
954+
#### `httpIntegration` options were consolidated
955+
956+
`httpIntegration` option names now match `httpServerIntegration` / `httpServerSpansIntegration` and the other server SDKs. The deprecated `instrumentation` hooks were removed.
957+
958+
| Removed option | Replacement |
959+
| --------------------------------------------- | ------------------------------------------------------------------------------- |
960+
| `trackIncomingRequestsAsSessions` | `sessions` |
961+
| `maxIncomingRequestBodySize` | `maxRequestBodySize` |
962+
| `ignoreIncomingRequestBody` | `ignoreRequestBody` |
963+
| `dropSpansForIncomingRequestStatusCodes` | `ignoreStatusCodes` |
964+
| `incomingRequestSpanHook` | `onSpanCreated` |
965+
| `instrumentation.requestHook` | `onSpanCreated` (incoming) or `outgoingRequestHook` (outgoing) |
966+
| `instrumentation.responseHook` | `onSpanCreated` (incoming) or `outgoingResponseHook` (outgoing) |
967+
| `instrumentation.applyCustomAttributesOnSpan` | `onSpanCreated` (incoming) or `outgoingRequestApplyCustomAttributes` (outgoing) |
968+
969+
```js
970+
// before
971+
Sentry.httpIntegration({
972+
trackIncomingRequestsAsSessions: false,
973+
maxIncomingRequestBodySize: 'small',
974+
ignoreIncomingRequestBody: url => url.includes('/health'),
975+
dropSpansForIncomingRequestStatusCodes: [404],
976+
incomingRequestSpanHook: (span, req, res) => {
977+
span.setAttribute('custom', true);
978+
},
979+
instrumentation: {
980+
responseHook: () => {
981+
void flushIfServerless();
982+
},
983+
},
984+
});
985+
986+
// after
987+
Sentry.httpIntegration({
988+
sessions: false,
989+
maxRequestBodySize: 'small',
990+
ignoreRequestBody: url => url.includes('/health'),
991+
ignoreStatusCodes: [404],
992+
onSpanCreated: (span, req, res) => {
993+
span.setAttribute('custom', true);
994+
},
995+
outgoingResponseHook: () => {
996+
void flushIfServerless();
997+
},
998+
});
999+
```
9551000
9561001
### `@sentry/cloudflare`
9571002

0 commit comments

Comments
 (0)