pub struct TransactionContext { /* private fields */ }
Expand description
The Transaction Context used to start a new Performance Monitoring Transaction.
The Transaction Context defines the metadata for a Performance Monitoring Transaction, and also the connection point for distributed tracing.
Implementations§
Source§impl TransactionContext
impl TransactionContext
Sourcepub fn new(name: &str, op: &str) -> Self
pub fn new(name: &str, op: &str) -> Self
Creates a new Transaction Context with the given name
and op
. A random
trace_id
is assigned. Use TransactionContext::new_with_trace_id
to
specify a custom trace ID.
See https://docs.sentry.io/platforms/native/enriching-events/transaction-name/
for an explanation of a Transaction’s name
, and
https://develop.sentry.dev/sdk/performance/span-operations/ for conventions
around an operation
’s value.
See also the TransactionContext::continue_from_headers
function that
can be used for distributed tracing.
Sourcepub fn new_with_trace_id(name: &str, op: &str, trace_id: TraceId) -> Self
pub fn new_with_trace_id(name: &str, op: &str, trace_id: TraceId) -> Self
Creates a new Transaction Context with the given name
, op
, and trace_id
.
See https://docs.sentry.io/platforms/native/enriching-events/transaction-name/
for an explanation of a Transaction’s name
, and
https://develop.sentry.dev/sdk/performance/span-operations/ for conventions
around an operation
’s value.
Sourcepub fn continue_from_headers<'a, I: IntoIterator<Item = (&'a str, &'a str)>>(
name: &str,
op: &str,
headers: I,
) -> Self
pub fn continue_from_headers<'a, I: IntoIterator<Item = (&'a str, &'a str)>>( name: &str, op: &str, headers: I, ) -> Self
Creates a new Transaction Context based on the distributed tracing headers
.
The headers
in particular need to include either the sentry-trace
or W3C
traceparent
header, which is used to associate the transaction with a distributed
trace. If both are present, sentry-trace
takes precedence.
Sourcepub fn continue_from_span(
name: &str,
op: &str,
span: Option<TransactionOrSpan>,
) -> Self
pub fn continue_from_span( name: &str, op: &str, span: Option<TransactionOrSpan>, ) -> Self
Creates a new Transaction Context based on an existing Span.
This should be used when an independent computation is spawned on another thread and should be connected to the calling thread via a distributed tracing transaction.
Sourcepub fn set_sampled(&mut self, sampled: impl Into<Option<bool>>)
pub fn set_sampled(&mut self, sampled: impl Into<Option<bool>>)
Set the sampling decision for this Transaction.
This can be either an explicit boolean flag, or None
, which will fall
back to use the configured traces_sample_rate
option.
Sourcepub fn custom(&self) -> Option<&CustomTransactionContext>
pub fn custom(&self) -> Option<&CustomTransactionContext>
Get the custom context of this Transaction.
Sourcepub fn custom_mut(&mut self) -> &mut Option<CustomTransactionContext>
pub fn custom_mut(&mut self) -> &mut Option<CustomTransactionContext>
Update the custom context of this Transaction.
For simply adding a key, use the custom_insert
method.
Sourcepub fn custom_insert(&mut self, key: String, value: Value) -> Option<Value>
pub fn custom_insert(&mut self, key: String, value: Value) -> Option<Value>
Inserts a key-value pair into the custom context.
If the context did not have this key present, None is returned.
If the context did have this key present, the value is updated, and the old value is returned.
Sourcepub fn builder(name: &str, op: &str) -> TransactionContextBuilder
pub fn builder(name: &str, op: &str) -> TransactionContextBuilder
Creates a transaction context builder initialized with the given name
and op
.
See https://docs.sentry.io/platforms/native/enriching-events/transaction-name/
for an explanation of a Transaction’s name
, and
https://develop.sentry.dev/sdk/performance/span-operations/ for conventions
around an operation
’s value.
Trait Implementations§
Source§impl Clone for TransactionContext
impl Clone for TransactionContext
Source§fn clone(&self) -> TransactionContext
fn clone(&self) -> TransactionContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more