1
1
/* eslint-disable max-lines */
2
2
import { getCurrentHub } from '@sentry/hub' ;
3
- import { Baggage , Hub , Primitive , Span as SpanInterface , SpanContext } from '@sentry/types' ;
3
+ import { Baggage , Hub , Primitive , Span as SpanInterface , SpanContext , Transaction } from '@sentry/types' ;
4
4
import {
5
5
createBaggage ,
6
6
dropUndefinedKeys ,
@@ -12,8 +12,6 @@ import {
12
12
uuid4 ,
13
13
} from '@sentry/utils' ;
14
14
15
- import { Transaction } from './transaction' ;
16
-
17
15
/**
18
16
* Keeps track of finished spans for a given transaction
19
17
* @internal
@@ -325,6 +323,11 @@ export class Span implements SpanInterface {
325
323
? this . _populateBaggageWithSentryValues ( existingBaggage )
326
324
: existingBaggage ;
327
325
326
+ // In case, we poulated the DSC, we have update the stored one on the transaction.
327
+ if ( existingBaggage !== finalBaggage && this . transaction ) {
328
+ this . transaction . metadata . baggage = finalBaggage ;
329
+ }
330
+
328
331
return finalBaggage ;
329
332
}
330
333
@@ -372,7 +375,9 @@ export class Span implements SpanInterface {
372
375
* @returns modified and immutable baggage object
373
376
*/
374
377
private _populateBaggageWithSentryValues ( baggage : Baggage = createBaggage ( { } ) ) : Baggage {
375
- const hub : Hub = ( this . transaction && this . transaction . _hub ) || getCurrentHub ( ) ;
378
+ // Because of a cicular dependency, we cannot import the Transaction class here, hence the type casts
379
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
380
+ const hub : Hub = ( ( this . transaction as any ) && ( this . transaction as any ) . _hub ) || getCurrentHub ( ) ;
376
381
const client = hub && hub . getClient ( ) ;
377
382
378
383
const { environment, release } = ( client && client . getOptions ( ) ) || { } ;
0 commit comments