File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 65
65
"access" : " public"
66
66
},
67
67
"dependencies" : {
68
+ "@opentelemetry/api" : " 1.7.0" ,
68
69
"@rollup/plugin-commonjs" : " 24.0.0" ,
69
70
"@sentry/core" : " 8.0.0-alpha.9" ,
70
71
"@sentry/node" : " 8.0.0-alpha.9" ,
71
72
"@sentry/react" : " 8.0.0-alpha.9" ,
72
73
"@sentry/types" : " 8.0.0-alpha.9" ,
73
74
"@sentry/utils" : " 8.0.0-alpha.9" ,
75
+ "@sentry/opentelemetry" : " 8.0.0-alpha.9" ,
74
76
"@sentry/vercel-edge" : " 8.0.0-alpha.9" ,
75
77
"@sentry/webpack-plugin" : " 2.16.0" ,
76
78
"chalk" : " 3.0.0" ,
Original file line number Diff line number Diff line change
1
+ import { SpanKind } from '@opentelemetry/api' ;
2
+ import { defineIntegration , spanToJSON } from '@sentry/core' ;
3
+ import { getSpanKind , getSpanScopes } from '@sentry/opentelemetry' ;
4
+
5
+ /**
6
+ * This integration is responsible for creating isolation scopes for incoming Http requests.
7
+ * We do so by waiting for http spans to be created and then forking the isolation scope.
8
+ *
9
+ * Normally the isolation scopes would be created by our Http instrumentation, however Next.js brings it's own Http
10
+ * instrumentation so we had to disable ours.
11
+ */
12
+ export const requestIsolationScopeIntegration = defineIntegration ( ( ) => {
13
+ return {
14
+ name : 'RequestIsolationScope' ,
15
+ setup ( client ) {
16
+ client . on ( 'spanStart' , span => {
17
+ const spanJson = spanToJSON ( span ) ;
18
+
19
+ // The following check is a heuristic to determine whether the started span is a span that tracks an incoming HTTP request
20
+ if ( getSpanKind ( span ) === SpanKind . SERVER && spanJson . data && 'http.method' in spanJson . data ) {
21
+ const scopes = getSpanScopes ( span ) ;
22
+ if ( scopes ) {
23
+ scopes . isolationScope = scopes . isolationScope . clone ( ) ;
24
+ }
25
+ }
26
+ } ) ;
27
+ } ,
28
+ } ;
29
+ } ) ;
You can’t perform that action at this time.
0 commit comments