Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Apr 15, 2024
1 parent 8845366 commit 8b02275
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Sentry.init({
async function run(): Promise<void> {
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
await new Promise(resolve => setTimeout(resolve, 100));
await fetch(`${process.env.SERVER_URL}/api/v0`);
await fetch(`${process.env.SERVER_URL}/api/v1`);
await fetch(`${process.env.SERVER_URL}/api/v2`);
await fetch(`${process.env.SERVER_URL}/api/v3`);
await fetch(`${process.env.SERVER_URL}/api/v0`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v2`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v3`).then(res => res.text());

Sentry.captureException(new Error('foo'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Sentry.init({
async function run(): Promise<void> {
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
await new Promise(resolve => setTimeout(resolve, 100));
await fetch(`${process.env.SERVER_URL}/api/v0`);
await fetch(`${process.env.SERVER_URL}/api/v1`);
await fetch(`${process.env.SERVER_URL}/api/v2`);
await fetch(`${process.env.SERVER_URL}/api/v3`);
await fetch(`${process.env.SERVER_URL}/api/v0`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v2`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v3`).then(res => res.text());

Sentry.captureException(new Error('foo'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ async function run(): Promise<void> {
await Sentry.startSpan({ name: 'test_span' }, async () => {
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
await new Promise(resolve => setTimeout(resolve, 100));
await fetch(`${process.env.SERVER_URL}/api/v0`);
await fetch(`${process.env.SERVER_URL}/api/v1`);
await fetch(`${process.env.SERVER_URL}/api/v2`);
await fetch(`${process.env.SERVER_URL}/api/v3`);
await fetch(`${process.env.SERVER_URL}/api/v0`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v2`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v3`).then(res => res.text());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ async function run(): Promise<void> {
await Sentry.startSpan({ name: 'outer' }, async () => {
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
await new Promise(resolve => setTimeout(resolve, 100));
await fetch(`${process.env.SERVER_URL}/api/v0`);
await fetch(`${process.env.SERVER_URL}/api/v1`);
await fetch(`${process.env.SERVER_URL}/api/v2`);
await fetch(`${process.env.SERVER_URL}/api/v3`);
await fetch(`${process.env.SERVER_URL}/api/v0`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v2`).then(res => res.text());
await fetch(`${process.env.SERVER_URL}/api/v3`).then(res => res.text());
});

Sentry.captureException(new Error('foo'));
Expand Down
11 changes: 6 additions & 5 deletions packages/node/src/integrations/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,22 @@ const _httpIntegration = ((options: HttpOptions = {}) => {
return false;
},

requireParentforOutgoingSpans: false,
requireParentforIncomingSpans: false,
requestHook: (span, req) => {
addOriginToSpan(span, 'auto.http.otel.http');

const scopes = getCapturedScopesOnSpan(span);

const isolationScope = (scopes.isolationScope || getIsolationScope()).clone();
const scope = scopes.scope || getCurrentScope();

// both, incoming requests and "client" requests made within the app trigger the requestHook
// we only want to isolate and further annotate incoming requests (IncomingMessage)
if (_isClientRequest(req)) {
return;
}

const scopes = getCapturedScopesOnSpan(span);

const isolationScope = (scopes.isolationScope || getIsolationScope()).clone();
const scope = scopes.scope || getCurrentScope();

// Update the isolation scope, isolate this request
isolationScope.setSDKProcessingMetadata({ request: req });

Expand Down

0 comments on commit 8b02275

Please sign in to comment.