File tree Expand file tree Collapse file tree 5 files changed +22
-21
lines changed
dev-packages/node-integration-tests/suites/tracing/requests
fetch-sampled-no-active-span
packages/node/src/integrations Expand file tree Collapse file tree 5 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,10 @@ Sentry.init({
12
12
async function run ( ) : Promise < void > {
13
13
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
14
14
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 ( ) ) ;
19
19
20
20
Sentry . captureException ( new Error ( 'foo' ) ) ;
21
21
}
Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ Sentry.init({
13
13
async function run ( ) : Promise < void > {
14
14
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
15
15
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 ( ) ) ;
20
20
21
21
Sentry . captureException ( new Error ( 'foo' ) ) ;
22
22
}
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ async function run(): Promise<void> {
14
14
await Sentry . startSpan ( { name : 'test_span' } , async ( ) => {
15
15
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
16
16
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 ( ) ) ;
21
21
} ) ;
22
22
}
23
23
Original file line number Diff line number Diff line change @@ -15,10 +15,10 @@ async function run(): Promise<void> {
15
15
await Sentry . startSpan ( { name : 'outer' } , async ( ) => {
16
16
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented
17
17
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 ( ) ) ;
22
22
} ) ;
23
23
24
24
Sentry . captureException ( new Error ( 'foo' ) ) ;
Original file line number Diff line number Diff line change @@ -88,21 +88,22 @@ const _httpIntegration = ((options: HttpOptions = {}) => {
88
88
return false ;
89
89
} ,
90
90
91
+ requireParentforOutgoingSpans : false ,
91
92
requireParentforIncomingSpans : false ,
92
93
requestHook : ( span , req ) => {
93
94
addOriginToSpan ( span , 'auto.http.otel.http' ) ;
94
95
95
- const scopes = getCapturedScopesOnSpan ( span ) ;
96
-
97
- const isolationScope = ( scopes . isolationScope || getIsolationScope ( ) ) . clone ( ) ;
98
- const scope = scopes . scope || getCurrentScope ( ) ;
99
-
100
96
// both, incoming requests and "client" requests made within the app trigger the requestHook
101
97
// we only want to isolate and further annotate incoming requests (IncomingMessage)
102
98
if ( _isClientRequest ( req ) ) {
103
99
return ;
104
100
}
105
101
102
+ const scopes = getCapturedScopesOnSpan ( span ) ;
103
+
104
+ const isolationScope = ( scopes . isolationScope || getIsolationScope ( ) ) . clone ( ) ;
105
+ const scope = scopes . scope || getCurrentScope ( ) ;
106
+
106
107
// Update the isolation scope, isolate this request
107
108
isolationScope . setSDKProcessingMetadata ( { request : req } ) ;
108
109
You can’t perform that action at this time.
0 commit comments