@@ -3,11 +3,10 @@ import type { Hub, Scope, TransactionMetadata } from '@sentry/types';
33
44import type { AbstractSpan } from '../types' ;
55
6- // We store the parent span, scope & metadata in separate weakmaps, so we can access them for a given span
6+ // We store the parent span, scopes & metadata in separate weakmaps, so we can access them for a given span
77// This way we can enhance the data that an OTEL Span natively gives us
88// and since we are using weakmaps, we do not need to clean up after ourselves
9- const SpanScope = new WeakMap < AbstractSpan , Scope > ( ) ;
10- const SpanFinishScopes = new WeakMap <
9+ const SpanScopes = new WeakMap <
1110 AbstractSpan ,
1211 {
1312 scope : Scope ;
@@ -18,16 +17,6 @@ const SpanHub = new WeakMap<AbstractSpan, Hub>();
1817const SpanParent = new WeakMap < AbstractSpan , Span > ( ) ;
1918const SpanMetadata = new WeakMap < AbstractSpan , Partial < TransactionMetadata > > ( ) ;
2019
21- /** Set the Sentry scope on an OTEL span. */
22- export function setSpanScope ( span : AbstractSpan , scope : Scope ) : void {
23- SpanScope . set ( span , scope ) ;
24- }
25-
26- /** Get the Sentry scope of an OTEL span. */
27- export function getSpanScope ( span : AbstractSpan ) : Scope | undefined {
28- return SpanScope . get ( span ) ;
29- }
30-
3120/** Set the Sentry hub on an OTEL span. */
3221export function setSpanHub ( span : AbstractSpan , hub : Hub ) : void {
3322 SpanHub . set ( span , hub ) ;
@@ -58,23 +47,27 @@ export function getSpanMetadata(span: AbstractSpan): Partial<TransactionMetadata
5847 return SpanMetadata . get ( span ) ;
5948}
6049
61- /** Set the Sentry scope to be used for finishing a given OTEL span. */
62- export function setSpanFinishScopes (
50+ /**
51+ * Set the Sentry scope to be used for finishing a given OTEL span.
52+ * This is different from `setCapturedScopesOnSpan`, as that works on _sentry_ spans,
53+ * while here we are basically "caching" this on the otel spans.
54+ */
55+ export function setSpanScopes (
6356 span : AbstractSpan ,
6457 scopes : {
6558 scope : Scope ;
6659 isolationScope : Scope ;
6760 } ,
6861) : void {
69- SpanFinishScopes . set ( span , scopes ) ;
62+ SpanScopes . set ( span , scopes ) ;
7063}
7164
72- /** Get the Sentry scope to use for finishing an OTEL span. */
73- export function getSpanFinishScopes ( span : AbstractSpan ) :
65+ /** Get the Sentry scopes to use for finishing an OTEL span. */
66+ export function getSpanScopes ( span : AbstractSpan ) :
7467 | {
7568 scope : Scope ;
7669 isolationScope : Scope ;
7770 }
7871 | undefined {
79- return SpanFinishScopes . get ( span ) ;
72+ return SpanScopes . get ( span ) ;
8073}
0 commit comments