Skip to content

Commit

Permalink
sentry-core: make TraceContext publicly readable (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommilligan authored Jan 13, 2023
1 parent abc2b34 commit 104cfae
Showing 1 changed file with 27 additions and 1 deletion.
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

0 comments on commit 104cfae

Please sign in to comment.