@@ -62,7 +62,7 @@ pub type CustomTransactionContext = serde_json::Map<String, serde_json::Value>;
62
62
///
63
63
/// The Transaction Context defines the metadata for a Performance Monitoring
64
64
/// Transaction, and also the connection point for distributed tracing.
65
- #[ derive( Debug ) ]
65
+ #[ derive( Debug , Clone ) ]
66
66
pub struct TransactionContext {
67
67
#[ cfg_attr( not( feature = "client" ) , allow( dead_code) ) ]
68
68
name : String ,
@@ -260,6 +260,16 @@ impl TransactionOrSpan {
260
260
}
261
261
}
262
262
263
+ /// Get the TransactionContext of the Transaction/Span.
264
+ ///
265
+ /// Note that this clones the underlying value.
266
+ pub fn get_trace_context ( & self ) -> protocol:: TraceContext {
267
+ match self {
268
+ TransactionOrSpan :: Transaction ( transaction) => transaction. get_trace_context ( ) ,
269
+ TransactionOrSpan :: Span ( span) => span. get_trace_context ( ) ,
270
+ }
271
+ }
272
+
263
273
/// Set the status of the Transaction/Span.
264
274
pub fn get_status ( & self ) -> Option < protocol:: SpanStatus > {
265
275
match self {
@@ -477,6 +487,14 @@ impl Transaction {
477
487
}
478
488
}
479
489
490
+ /// Get the TransactionContext of the Transaction.
491
+ ///
492
+ /// Note that this clones the underlying value.
493
+ pub fn get_trace_context ( & self ) -> protocol:: TraceContext {
494
+ let inner = self . inner . lock ( ) . unwrap ( ) ;
495
+ inner. context . clone ( )
496
+ }
497
+
480
498
/// Get the status of the Transaction.
481
499
pub fn get_status ( & self ) -> Option < protocol:: SpanStatus > {
482
500
let inner = self . inner . lock ( ) . unwrap ( ) ;
@@ -601,6 +619,14 @@ impl Span {
601
619
span. data . insert ( key. into ( ) , value) ;
602
620
}
603
621
622
+ /// Get the TransactionContext of the Span.
623
+ ///
624
+ /// Note that this clones the underlying value.
625
+ pub fn get_trace_context ( & self ) -> protocol:: TraceContext {
626
+ let transaction = self . transaction . lock ( ) . unwrap ( ) ;
627
+ transaction. context . clone ( )
628
+ }
629
+
604
630
/// Get the status of the Span.
605
631
pub fn get_status ( & self ) -> Option < protocol:: SpanStatus > {
606
632
let span = self . span . lock ( ) . unwrap ( ) ;
0 commit comments