@@ -75,6 +75,11 @@ class Scope
75
75
*/
76
76
private $ span ;
77
77
78
+ /**
79
+ * @var string|null The transaction name
80
+ */
81
+ private $ transactionName ;
82
+
78
83
/**
79
84
* @var callable[] List of event processors
80
85
*
@@ -363,6 +368,10 @@ public function applyToEvent(Event $event, ?EventHint $hint = null, ?Options $op
363
368
$ event ->setExtra (array_merge ($ this ->extra , $ event ->getExtra ()));
364
369
}
365
370
371
+ if ($ this ->transactionName !== null ) {
372
+ $ event ->setTransaction ($ this ->transactionName );
373
+ }
374
+
366
375
if ($ this ->user !== null ) {
367
376
$ user = $ event ->getUser ();
368
377
@@ -460,6 +469,25 @@ public function getTransaction(): ?Transaction
460
469
return null ;
461
470
}
462
471
472
+ /**
473
+ * Set the transaction name on the scope as well as on the transaction
474
+ * attached to the scope (if there is one).
475
+ */
476
+ public function setTransactionName (string $ name ): self
477
+ {
478
+ $ this ->transactionName = $ name ;
479
+
480
+ // If we have an active transaction, update its name as well
481
+ if ($ this ->span !== null ) {
482
+ $ transaction = $ this ->span ->getTransaction ();
483
+ if ($ transaction !== null ) {
484
+ $ transaction ->setName ($ name );
485
+ }
486
+ }
487
+
488
+ return $ this ;
489
+ }
490
+
463
491
public function getPropagationContext (): PropagationContext
464
492
{
465
493
return $ this ->propagationContext ;
0 commit comments