Skip to content

Commit e65304d

Browse files
authored
Merge a15b835 into abc2b34
2 parents abc2b34 + a15b835 commit e65304d

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

sentry-core/src/performance.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub type CustomTransactionContext = serde_json::Map<String, serde_json::Value>;
6262
///
6363
/// The Transaction Context defines the metadata for a Performance Monitoring
6464
/// Transaction, and also the connection point for distributed tracing.
65-
#[derive(Debug)]
65+
#[derive(Debug, Clone)]
6666
pub struct TransactionContext {
6767
#[cfg_attr(not(feature = "client"), allow(dead_code))]
6868
name: String,
@@ -260,6 +260,16 @@ impl TransactionOrSpan {
260260
}
261261
}
262262

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+
263273
/// Set the status of the Transaction/Span.
264274
pub fn get_status(&self) -> Option<protocol::SpanStatus> {
265275
match self {
@@ -477,6 +487,14 @@ impl Transaction {
477487
}
478488
}
479489

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+
480498
/// Get the status of the Transaction.
481499
pub fn get_status(&self) -> Option<protocol::SpanStatus> {
482500
let inner = self.inner.lock().unwrap();
@@ -601,6 +619,14 @@ impl Span {
601619
span.data.insert(key.into(), value);
602620
}
603621

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+
604630
/// Get the status of the Span.
605631
pub fn get_status(&self) -> Option<protocol::SpanStatus> {
606632
let span = self.span.lock().unwrap();

0 commit comments

Comments
 (0)