@@ -81,6 +81,7 @@ class Scope(object):
81
81
# note that for legacy reasons, _transaction is the transaction *name*,
82
82
# not a Transaction object (the object is stored in _span)
83
83
"_transaction" ,
84
+ "_transaction_info" ,
84
85
"_user" ,
85
86
"_tags" ,
86
87
"_contexts" ,
@@ -109,6 +110,7 @@ def clear(self):
109
110
self ._level = None # type: Optional[str]
110
111
self ._fingerprint = None # type: Optional[List[str]]
111
112
self ._transaction = None # type: Optional[str]
113
+ self ._transaction_info = {} # type: Dict[str, str]
112
114
self ._user = None # type: Optional[Dict[str, Any]]
113
115
114
116
self ._tags = {} # type: Dict[str, Any]
@@ -176,6 +178,17 @@ def transaction(self, value):
176
178
if self ._span and self ._span .containing_transaction :
177
179
self ._span .containing_transaction .name = value
178
180
181
+ def set_transaction_name (self , name , source = None ):
182
+ # type: (str, Optional[str]) -> None
183
+ """Set the transaction name and optionally the transaction source."""
184
+ self ._transaction = name
185
+
186
+ if self ._span and self ._span .containing_transaction :
187
+ self ._span .containing_transaction .name = name
188
+
189
+ if source :
190
+ self ._transaction_info ["source" ] = source
191
+
179
192
@_attr_setter
180
193
def user (self , value ):
181
194
# type: (Optional[Dict[str, Any]]) -> None
@@ -363,6 +376,9 @@ def _drop(event, cause, ty):
363
376
if event .get ("transaction" ) is None and self ._transaction is not None :
364
377
event ["transaction" ] = self ._transaction
365
378
379
+ if event .get ("transaction_info" ) is None and self ._transaction_info is not None :
380
+ event ["transaction_info" ] = self ._transaction_info
381
+
366
382
if event .get ("fingerprint" ) is None and self ._fingerprint is not None :
367
383
event ["fingerprint" ] = self ._fingerprint
368
384
@@ -406,6 +422,8 @@ def update_from_scope(self, scope):
406
422
self ._fingerprint = scope ._fingerprint
407
423
if scope ._transaction is not None :
408
424
self ._transaction = scope ._transaction
425
+ if scope ._transaction_info is not None :
426
+ self ._transaction_info .update (scope ._transaction_info )
409
427
if scope ._user is not None :
410
428
self ._user = scope ._user
411
429
if scope ._tags :
@@ -452,6 +470,7 @@ def __copy__(self):
452
470
rv ._name = self ._name
453
471
rv ._fingerprint = self ._fingerprint
454
472
rv ._transaction = self ._transaction
473
+ rv ._transaction_info = dict (self ._transaction_info )
455
474
rv ._user = self ._user
456
475
457
476
rv ._tags = dict (self ._tags )
0 commit comments