@@ -84,7 +84,7 @@ impl TransactionContext {
84
84
/// can be used for distributed tracing.
85
85
#[ must_use = "this must be used with `start_transaction`" ]
86
86
pub fn new ( name : & str , op : & str ) -> Self {
87
- Self :: continue_from_headers ( name, op, vec ! [ ] )
87
+ Self :: continue_from_headers ( name, op, std :: iter :: empty ( ) )
88
88
}
89
89
90
90
/// Creates a new Transaction Context based on the distributed tracing `headers`.
@@ -200,7 +200,8 @@ impl TransactionContext {
200
200
///
201
201
/// If the context did not have this key present, None is returned.
202
202
///
203
- /// If the context did have this key present, the value is updated, and the old value is returned.
203
+ /// If the context did have this key present, the value is updated, and the old value is
204
+ /// returned.
204
205
pub fn custom_insert (
205
206
& mut self ,
206
207
key : String ,
@@ -301,6 +302,14 @@ impl TransactionOrSpan {
301
302
}
302
303
}
303
304
305
+ /// Get the sampling decision for this Transaction/Span.
306
+ pub fn is_sampled ( & self ) -> bool {
307
+ match self {
308
+ TransactionOrSpan :: Transaction ( transaction) => transaction. is_sampled ( ) ,
309
+ TransactionOrSpan :: Span ( span) => span. is_sampled ( ) ,
310
+ }
311
+ }
312
+
304
313
/// Starts a new child Span with the given `op` and `description`.
305
314
///
306
315
/// The span must be explicitly finished via [`Span::finish`], as it will
@@ -483,7 +492,8 @@ impl Transaction {
483
492
}
484
493
}
485
494
486
- /// Returns an iterating accessor to the transaction's [`extra` field](protocol::Transaction::extra).
495
+ /// Returns an iterating accessor to the transaction's
496
+ /// [`extra` field](protocol::Transaction::extra).
487
497
///
488
498
/// # Concurrency
489
499
/// In order to obtain any kind of reference to the `extra` field,
@@ -536,6 +546,11 @@ impl Transaction {
536
546
}
537
547
}
538
548
549
+ /// Get the sampling decision for this Transaction.
550
+ pub fn is_sampled ( & self ) -> bool {
551
+ self . inner . lock ( ) . unwrap ( ) . sampled
552
+ }
553
+
539
554
/// Finishes the Transaction.
540
555
///
541
556
/// This records the end timestamp and sends the transaction together with
@@ -708,6 +723,11 @@ impl Span {
708
723
}
709
724
}
710
725
726
+ /// Get the sampling decision for this Span.
727
+ pub fn is_sampled ( & self ) -> bool {
728
+ self . sampled
729
+ }
730
+
711
731
/// Finishes the Span.
712
732
///
713
733
/// This will record the end timestamp and add the span to the transaction
0 commit comments