Struct sentry::TransactionContext

source ·
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

source

pub fn new(name: &str, op: &str) -> TransactionContext

Creates a new Transaction Context 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.

See also the TransactionContext::continue_from_headers function that can be used for distributed tracing.

source

pub fn continue_from_headers<'a, I>( name: &str, op: &str, headers: I ) -> TransactionContext
where I: IntoIterator<Item = (&'a str, &'a str)>,

Creates a new Transaction Context based on the distributed tracing headers.

The headers in particular need to include the sentry-trace header, which is used to associate the transaction with a distributed trace.

source

pub fn continue_from_span( name: &str, op: &str, span: Option<TransactionOrSpan> ) -> TransactionContext

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.

source

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.

source

pub fn sampled(&self) -> Option<bool>

Get the sampling decision for this Transaction.

source

pub fn name(&self) -> &str

Get the name of this Transaction.

source

pub fn operation(&self) -> &str

Get the operation of this Transaction.

source

pub fn trace_id(&self) -> TraceId

Get the Trace ID of this Transaction.

source

pub fn custom(&self) -> Option<&Map<String, Value>>

Get the custom context of this Transaction.

source

pub fn custom_mut(&mut self) -> &mut Option<Map<String, Value>>

Update the custom context of this Transaction.

For simply adding a key, use the custom_insert method.

source

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.

Trait Implementations§

source§

impl Clone for TransactionContext

source§

fn clone(&self) -> TransactionContext

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TransactionContext

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,