Skip to content

Commit 8b02275

Browse files
committed
PR feedback
1 parent 8845366 commit 8b02275

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

dev-packages/node-integration-tests/suites/tracing/requests/fetch-noSampleRate/scenario.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Sentry.init({
1212
async function run(): Promise<void> {
1313
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
1414
await new Promise(resolve => setTimeout(resolve, 100));
15-
await fetch(`${process.env.SERVER_URL}/api/v0`);
16-
await fetch(`${process.env.SERVER_URL}/api/v1`);
17-
await fetch(`${process.env.SERVER_URL}/api/v2`);
18-
await fetch(`${process.env.SERVER_URL}/api/v3`);
15+
await fetch(`${process.env.SERVER_URL}/api/v0`).then(res => res.text());
16+
await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text());
17+
await fetch(`${process.env.SERVER_URL}/api/v2`).then(res => res.text());
18+
await fetch(`${process.env.SERVER_URL}/api/v3`).then(res => res.text());
1919

2020
Sentry.captureException(new Error('foo'));
2121
}

dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/scenario.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Sentry.init({
1313
async function run(): Promise<void> {
1414
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
1515
await new Promise(resolve => setTimeout(resolve, 100));
16-
await fetch(`${process.env.SERVER_URL}/api/v0`);
17-
await fetch(`${process.env.SERVER_URL}/api/v1`);
18-
await fetch(`${process.env.SERVER_URL}/api/v2`);
19-
await fetch(`${process.env.SERVER_URL}/api/v3`);
16+
await fetch(`${process.env.SERVER_URL}/api/v0`).then(res => res.text());
17+
await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text());
18+
await fetch(`${process.env.SERVER_URL}/api/v2`).then(res => res.text());
19+
await fetch(`${process.env.SERVER_URL}/api/v3`).then(res => res.text());
2020

2121
Sentry.captureException(new Error('foo'));
2222
}

dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled/scenario.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ async function run(): Promise<void> {
1414
await Sentry.startSpan({ name: 'test_span' }, async () => {
1515
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
1616
await new Promise(resolve => setTimeout(resolve, 100));
17-
await fetch(`${process.env.SERVER_URL}/api/v0`);
18-
await fetch(`${process.env.SERVER_URL}/api/v1`);
19-
await fetch(`${process.env.SERVER_URL}/api/v2`);
20-
await fetch(`${process.env.SERVER_URL}/api/v3`);
17+
await fetch(`${process.env.SERVER_URL}/api/v0`).then(res => res.text());
18+
await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text());
19+
await fetch(`${process.env.SERVER_URL}/api/v2`).then(res => res.text());
20+
await fetch(`${process.env.SERVER_URL}/api/v3`).then(res => res.text());
2121
});
2222
}
2323

dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/scenario.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ async function run(): Promise<void> {
1515
await Sentry.startSpan({ name: 'outer' }, async () => {
1616
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
1717
await new Promise(resolve => setTimeout(resolve, 100));
18-
await fetch(`${process.env.SERVER_URL}/api/v0`);
19-
await fetch(`${process.env.SERVER_URL}/api/v1`);
20-
await fetch(`${process.env.SERVER_URL}/api/v2`);
21-
await fetch(`${process.env.SERVER_URL}/api/v3`);
18+
await fetch(`${process.env.SERVER_URL}/api/v0`).then(res => res.text());
19+
await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text());
20+
await fetch(`${process.env.SERVER_URL}/api/v2`).then(res => res.text());
21+
await fetch(`${process.env.SERVER_URL}/api/v3`).then(res => res.text());
2222
});
2323

2424
Sentry.captureException(new Error('foo'));

packages/node/src/integrations/http.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,22 @@ const _httpIntegration = ((options: HttpOptions = {}) => {
8888
return false;
8989
},
9090

91+
requireParentforOutgoingSpans: false,
9192
requireParentforIncomingSpans: false,
9293
requestHook: (span, req) => {
9394
addOriginToSpan(span, 'auto.http.otel.http');
9495

95-
const scopes = getCapturedScopesOnSpan(span);
96-
97-
const isolationScope = (scopes.isolationScope || getIsolationScope()).clone();
98-
const scope = scopes.scope || getCurrentScope();
99-
10096
// both, incoming requests and "client" requests made within the app trigger the requestHook
10197
// we only want to isolate and further annotate incoming requests (IncomingMessage)
10298
if (_isClientRequest(req)) {
10399
return;
104100
}
105101

102+
const scopes = getCapturedScopesOnSpan(span);
103+
104+
const isolationScope = (scopes.isolationScope || getIsolationScope()).clone();
105+
const scope = scopes.scope || getCurrentScope();
106+
106107
// Update the isolation scope, isolate this request
107108
isolationScope.setSDKProcessingMetadata({ request: req });
108109

0 commit comments

Comments
 (0)