pub struct TracingEventReceiver { /* private fields */ }
Available on crate feature receiver only.
Expand description

Receiver of TracingEvents produced by TracingEventSender that relays them to the tracing infrastructure.

The receiver takes care of persisting Metadata / spans that can outlive the lifetime of the host program (not just the TracingEventReceiver instance!). As an example, in the Tardigrade runtime, a consumer instance is created each time a workflow is executed. It relays tracing events from the workflow logic (executed in WASM) to the host.

In some cases, the execution tracked by TracingEventReceiver may finish abnormally. (E.g., a WASM module instance panics while it has the panic = abort set in the compilation options.) In these cases, all entered spans are force-exited when the receiver is dropped. Additionally, spans created by the execution are closed on drop as long as they are not persisted. That is, persistence acts as a commitment of the execution results, while the default behavior is rollback.

⚠ Resource consumption

To fit the API of the tracing-core crate, the receiver leaks string parts of CallSiteData: we need a &'static str when we only have a String. Steps are taken to limit the amount of leaked memory; we use a static string arena which checks whether a particular string was already leaked, and reuses the existing &'static str if possible. Still, this has negative implications regarding both memory consumption and performance, so you probably should limit the number of executables to use with a TracingEventReceiver. The number of executions of each executable is not a limiting factor.

Examples

See crate-level docs for an example of usage.

Implementations§

Restores the receiver from the persisted metadata and tracing spans.

A receiver will work fine if local_spans information is lost (e.g., reset to the default empty value). However, this is likely to result in span leakage in the underlying Subscriber. On the other hand, mismatch between metadata / spans and the execution producing TracingEvents is bad; it will most likely result in errors returned from Self::try_receive().

Tries to consume an event and relays it to the tracing infrastructure.

Errors

Fails if the event contains a bogus reference to a call site or a span, or if it contains too many values. In general, an error can mean that the consumer was restored from an incorrect persisted state, or that the event generator is bogus (e.g., not a TracingEventSender).

Consumes an event and relays it to the tracing infrastructure.

Panics

Panics in the same cases when Self::try_receive() returns an error.

Persists Metadata produced by the previously consumed events. The returned metadata should be merged into the metadata provided to Self::new().

Returns persisted and local spans.

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.