@@ -2,42 +2,39 @@ import type { Context } from '@opentelemetry/api';
22import { ROOT_CONTEXT , trace } from '@opentelemetry/api' ;
33import type { Span , SpanProcessor as SpanProcessorInterface } from '@opentelemetry/sdk-trace-base' ;
44import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base' ;
5- import { getClient , getCurrentHub } from '@sentry/core' ;
5+ import { getClient , getDefaultCurrentScope , getDefaultIsolationScope } from '@sentry/core' ;
66import { logger } from '@sentry/utils' ;
77
88import { DEBUG_BUILD } from './debug-build' ;
99import { SentrySpanExporter } from './spanExporter' ;
1010import { maybeCaptureExceptionForTimedEvent } from './utils/captureExceptionForTimedEvent' ;
11- import { getHubFromContext } from './utils/contextData' ;
11+ import { getScopesFromContext } from './utils/contextData' ;
1212import { setIsSetup } from './utils/setupCheck' ;
13- import { getSpanHub , setSpanHub , setSpanParent , setSpanScopes } from './utils/spanData' ;
13+ import { setSpanParent , setSpanScopes } from './utils/spanData' ;
1414
1515function onSpanStart ( span : Span , parentContext : Context ) : void {
1616 // This is a reliable way to get the parent span - because this is exactly how the parent is identified in the OTEL SDK
1717 const parentSpan = trace . getSpan ( parentContext ) ;
18- const hub = getHubFromContext ( parentContext ) ;
18+
19+ let scopes = getScopesFromContext ( parentContext ) ;
1920
2021 // We need access to the parent span in order to be able to move up the span tree for breadcrumbs
2122 if ( parentSpan ) {
2223 setSpanParent ( span , parentSpan ) ;
2324 }
2425
25- // The root context does not have a hub stored, so we check for this specifically
26- // We do this instead of just falling back to `getCurrentHub` to avoid attaching the wrong hub
27- let actualHub = hub ;
26+ // The root context does not have scopes stored, so we check for this specifically
27+ // As fallback we attach the global scopes
2828 if ( parentContext === ROOT_CONTEXT ) {
29- // eslint-disable-next-line deprecation/deprecation
30- actualHub = getCurrentHub ( ) ;
29+ scopes = {
30+ scope : getDefaultCurrentScope ( ) ,
31+ isolationScope : getDefaultIsolationScope ( ) ,
32+ } ;
3133 }
3234
3335 // We need the scope at time of span creation in order to apply it to the event when the span is finished
34- if ( actualHub ) {
35- // eslint-disable-next-line deprecation/deprecation
36- const scope = actualHub . getScope ( ) ;
37- // eslint-disable-next-line deprecation/deprecation
38- const isolationScope = actualHub . getIsolationScope ( ) ;
39- setSpanHub ( span , actualHub ) ;
40- setSpanScopes ( span , { scope, isolationScope } ) ;
36+ if ( scopes ) {
37+ setSpanScopes ( span , scopes ) ;
4138 }
4239
4340 const client = getClient ( ) ;
@@ -46,10 +43,8 @@ function onSpanStart(span: Span, parentContext: Context): void {
4643
4744function onSpanEnd ( span : Span ) : void {
4845 // Capture exceptions as events
49- // eslint-disable-next-line deprecation/deprecation
50- const hub = getSpanHub ( span ) || getCurrentHub ( ) ;
5146 span . events . forEach ( event => {
52- maybeCaptureExceptionForTimedEvent ( hub , event , span ) ;
47+ maybeCaptureExceptionForTimedEvent ( event , span ) ;
5348 } ) ;
5449
5550 const client = getClient ( ) ;
0 commit comments