File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -392,6 +392,10 @@ export class Scope implements ScopeInterface {
392
392
// errors with transaction and it relys on that.
393
393
if ( this . _span ) {
394
394
event . contexts = { trace : this . _span . getTraceContext ( ) , ...event . contexts } ;
395
+ const transactionName = this . _span . transaction ?. name ;
396
+ if ( transactionName ) {
397
+ event . tags = { transaction : transactionName , ...event . tags } ;
398
+ }
395
399
}
396
400
397
401
this . _applyFingerprint ( event ) ;
Original file line number Diff line number Diff line change @@ -297,6 +297,38 @@ describe('Scope', () => {
297
297
} ) ;
298
298
} ) ;
299
299
300
+ test ( 'applyToEvent transaction name tag when transaction on scope' , async ( ) => {
301
+ expect . assertions ( 1 ) ;
302
+ const scope = new Scope ( ) ;
303
+ const transaction = {
304
+ fake : 'span' ,
305
+ getTraceContext : ( ) => ( { a : 'b' } ) ,
306
+ name : 'fake transaction' ,
307
+ } as any ;
308
+ transaction . transaction = transaction ; // because this is a transaction, its transaction pointer points to itself
309
+ scope . setSpan ( transaction ) ;
310
+ const event : Event = { } ;
311
+ return scope . applyToEvent ( event ) . then ( processedEvent => {
312
+ expect ( processedEvent ! . tags ! . transaction ) . toEqual ( 'fake transaction' ) ;
313
+ } ) ;
314
+ } ) ;
315
+
316
+ test ( 'applyToEvent transaction name tag when span on scope' , async ( ) => {
317
+ expect . assertions ( 1 ) ;
318
+ const scope = new Scope ( ) ;
319
+ const transaction = { name : 'fake transaction' } ;
320
+ const span = {
321
+ fake : 'span' ,
322
+ getTraceContext : ( ) => ( { a : 'b' } ) ,
323
+ transaction,
324
+ } as any ;
325
+ scope . setSpan ( span ) ;
326
+ const event : Event = { } ;
327
+ return scope . applyToEvent ( event ) . then ( processedEvent => {
328
+ expect ( processedEvent ! . tags ! . transaction ) . toEqual ( 'fake transaction' ) ;
329
+ } ) ;
330
+ } ) ;
331
+
300
332
test ( 'clear' , ( ) => {
301
333
const scope = new Scope ( ) ;
302
334
scope . setExtra ( 'a' , 2 ) ;
You can’t perform that action at this time.
0 commit comments