@@ -526,32 +526,32 @@ pub struct Transaction {
526526 pub ( crate ) inner : TransactionArc ,
527527}
528528
529- /// Iterable for a transaction's [`extra` field ](protocol::Transaction::extra ).
529+ /// Iterable for a transaction's [data attributes ](protocol::TraceContext::data ).
530530pub struct TransactionData < ' a > ( MutexGuard < ' a , TransactionInner > ) ;
531531
532532impl < ' a > TransactionData < ' a > {
533- /// Iterate over the `extra` map
534- /// of the [transaction][protocol::Transaction].
533+ /// Iterate over the [data attributes](protocol::TraceContext::data)
534+ /// associated with this [transaction][protocol::Transaction].
535535 ///
536- /// If the transaction not sampled for sending,
537- /// the metadata will not be populated at all
536+ /// If the transaction is not sampled for sending,
537+ /// the metadata will not be populated at all,
538538 /// so the produced iterator is empty.
539539 pub fn iter ( & self ) -> Box < dyn Iterator < Item = ( & String , & protocol:: Value ) > + ' _ > {
540- if let Some ( ref rx ) = self . 0 . transaction {
541- Box :: new ( rx . extra . iter ( ) )
540+ if self . 0 . transaction . is_some ( ) {
541+ Box :: new ( self . 0 . context . data . iter ( ) )
542542 } else {
543543 Box :: new ( std:: iter:: empty ( ) )
544544 }
545545 }
546546
547- /// Set some extra information to be sent with this Transaction.
547+ /// Set a data attribute to be sent with this Transaction.
548548 pub fn set_data ( & mut self , key : Cow < ' a , str > , value : protocol:: Value ) {
549- if let Some ( transaction ) = self . 0 . transaction . as_mut ( ) {
550- transaction . extra . insert ( key. into ( ) , value) ;
549+ if self . 0 . transaction . is_some ( ) {
550+ self . 0 . context . data . insert ( key. into ( ) , value) ;
551551 }
552552 }
553553
554- /// Set some extra information to be sent with this Transaction.
554+ /// Set a tag to be sent with this Transaction.
555555 pub fn set_tag ( & mut self , key : Cow < ' _ , str > , value : String ) {
556556 if let Some ( transaction) = self . 0 . transaction . as_mut ( ) {
557557 transaction. tags . insert ( key. into ( ) , value) ;
@@ -610,8 +610,16 @@ impl Transaction {
610610 }
611611 }
612612
613- /// Set some extra information to be sent with this Transaction.
613+ /// Set a data attribute to be sent with this Transaction.
614614 pub fn set_data ( & self , key : & str , value : protocol:: Value ) {
615+ let mut inner = self . inner . lock ( ) . unwrap ( ) ;
616+ if inner. transaction . is_some ( ) {
617+ inner. context . data . insert ( key. into ( ) , value) ;
618+ }
619+ }
620+
621+ /// Set some extra information to be sent with this Transaction.
622+ pub fn set_extra ( & self , key : & str , value : protocol:: Value ) {
615623 let mut inner = self . inner . lock ( ) . unwrap ( ) ;
616624 if let Some ( transaction) = inner. transaction . as_mut ( ) {
617625 transaction. extra . insert ( key. into ( ) , value) ;
@@ -627,10 +635,10 @@ impl Transaction {
627635 }
628636
629637 /// Returns an iterating accessor to the transaction's
630- /// [`extra` field ](protocol::Transaction::extra ).
638+ /// [data attributes ](protocol::TraceContext::data ).
631639 ///
632640 /// # Concurrency
633- /// In order to obtain any kind of reference to the `extra ` field,
641+ /// In order to obtain any kind of reference to the `TraceContext::data ` field,
634642 /// a `Mutex` needs to be locked. The returned `TransactionData` holds on to this lock
635643 /// for as long as it lives. Therefore you must take care not to keep the returned
636644 /// `TransactionData` around too long or it will never relinquish the lock and you may run into
0 commit comments