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 45
45
"access" : " public"
46
46
},
47
47
"dependencies" : {
48
+ "@opentelemetry/api" : " 1.7.0" ,
48
49
"@rollup/plugin-commonjs" : " 24.0.0" ,
49
50
"@sentry/core" : " 8.0.0-alpha.7" ,
50
51
"@sentry/node" : " 8.0.0-alpha.7" ,
51
52
"@sentry/react" : " 8.0.0-alpha.7" ,
52
53
"@sentry/types" : " 8.0.0-alpha.7" ,
53
54
"@sentry/utils" : " 8.0.0-alpha.7" ,
55
+ "@sentry/opentelemetry" : " 8.0.0-alpha.7" ,
54
56
"@sentry/vercel-edge" : " 8.0.0-alpha.7" ,
55
57
"@sentry/webpack-plugin" : " 2.16.0" ,
56
58
"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