Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion sentry-core/src/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub type CustomTransactionContext = serde_json::Map<String, serde_json::Value>;
///
/// The Transaction Context defines the metadata for a Performance Monitoring
/// Transaction, and also the connection point for distributed tracing.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct TransactionContext {
#[cfg_attr(not(feature = "client"), allow(dead_code))]
name: String,
Expand Down Expand Up @@ -260,6 +260,16 @@ impl TransactionOrSpan {
}
}

/// Get the TransactionContext of the Transaction/Span.
///
/// Note that this clones the underlying value.
pub fn get_trace_context(&self) -> protocol::TraceContext {
match self {
TransactionOrSpan::Transaction(transaction) => transaction.get_trace_context(),
TransactionOrSpan::Span(span) => span.get_trace_context(),
}
}

/// Set the status of the Transaction/Span.
pub fn get_status(&self) -> Option<protocol::SpanStatus> {
match self {
Expand Down Expand Up @@ -477,6 +487,14 @@ impl Transaction {
}
}

/// Get the TransactionContext of the Transaction.
///
/// Note that this clones the underlying value.
pub fn get_trace_context(&self) -> protocol::TraceContext {
let inner = self.inner.lock().unwrap();
inner.context.clone()
}

/// Get the status of the Transaction.
pub fn get_status(&self) -> Option<protocol::SpanStatus> {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -601,6 +619,14 @@ impl Span {
span.data.insert(key.into(), value);
}

/// Get the TransactionContext of the Span.
///
/// Note that this clones the underlying value.
pub fn get_trace_context(&self) -> protocol::TraceContext {
let transaction = self.transaction.lock().unwrap();
transaction.context.clone()
}

/// Get the status of the Span.
pub fn get_status(&self) -> Option<protocol::SpanStatus> {
let span = self.span.lock().unwrap();
Expand Down