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 6565 "access" : " public"
6666 },
6767 "dependencies" : {
68+ "@opentelemetry/api" : " 1.7.0" ,
6869 "@rollup/plugin-commonjs" : " 24.0.0" ,
6970 "@sentry/core" : " 8.0.0-alpha.9" ,
7071 "@sentry/node" : " 8.0.0-alpha.9" ,
7172 "@sentry/react" : " 8.0.0-alpha.9" ,
7273 "@sentry/types" : " 8.0.0-alpha.9" ,
7374 "@sentry/utils" : " 8.0.0-alpha.9" ,
75+ "@sentry/opentelemetry" : " 8.0.0-alpha.9" ,
7476 "@sentry/vercel-edge" : " 8.0.0-alpha.9" ,
7577 "@sentry/webpack-plugin" : " 2.16.0" ,
7678 "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