logo

Struct tracing_flame::FlameLayer[][src]

pub struct FlameLayer<S, W> { /* fields omitted */ }
Expand description

A Layer that records span open/close events as folded flamegraph stack samples.

The output of FlameLayer emulates the output of commands like perf once they’ve been collapsed by inferno-flamegraph. The output of this layer should look similar to the output of the following commands:

perf record --call-graph dwarf target/release/mybin
perf script | inferno-collapse-perf > stacks.folded

Sample Counts

Because tracing-flame doesn’t use sampling, the number at the end of each folded stack trace does not represent a number of samples of that stack. Instead, the numbers on each line are the number of nanoseconds since the last event in the same thread.

Dropping and Flushing

If you use a global subscriber the drop implementations on your various layers will not get called when your program exits. This means that if you’re using a buffered writer as the inner writer for the FlameLayer you’re not guaranteed to see all the events that have been emitted in the file by default.

To ensure all data is flushed when the program exits, FlameLayer exposes the flush_on_drop function, which returns a FlushGuard. The FlushGuard will flush the writer when it is dropped. If necessary, it can also be used to manually flush the writer.

Implementations

Returns a new FlameLayer that outputs all folded stack samples to the provided writer.

Returns a FlushGuard which will flush the FlameLayer’s writer when it is dropped, or when flush is manually invoked on the guard.

Configures whether or not periods of time where no spans are entered should be included in the output.

Defaults to true.

Setting this feature to false can help with situations where no span is active for large periods of time. This can include time spent idling, or doing uninteresting work that isn’t being measured. When a large number of empty samples are recorded, the flamegraph may be harder to interpret and navigate, since the recorded spans will take up a correspondingly smaller percentage of the graph. In some cases, a large number of empty samples may even hide spans which would otherwise appear in the flamegraph.

Configures whether or not spans from different threads should be collapsed into one pool of events.

Defaults to false.

Setting this feature to true can help with applications that distribute work evenly across many threads, such as thread pools. In such cases it can be difficult to get an overview of where the application as a whole spent most of its time, because work done in the same span may be split up across many threads.

Configures whether or not module paths should be included in the output.

Configures whether or not file and line should be included in the output.

Constructs a FlameLayer that outputs to a BufWriter to the given path, and a FlushGuard to ensure the writer is flushed.

Trait Implementations

Formats the value using the given formatter. Read more

Notifies this layer that a span with the given ID was entered.

Notifies this layer that the span with the given ID was exited.

Performs late initialization when attaching a Layer to a Subscriber. Read more

Registers a new callsite with this layer, returning whether or not the layer is interested in being notified about the callsite, similarly to Subscriber::register_callsite. Read more

Returns true if this layer is interested in a span or event with the given metadata in the current Context, similarly to Subscriber::enabled. Read more

Notifies this layer that a new span was constructed with the given Attributes and Id. Read more

Notifies this layer that a span with the given Id recorded the given values. Read more

Notifies this layer that a span with the ID span recorded that it follows from the span with the ID follows. Read more

Notifies this layer that an event has occurred.

Notifies this layer that the span with the given ID has been closed.

Notifies this layer that a span ID has been cloned, and that the subscriber returned a different ID. Read more

Composes this layer around the given Layer, returning a Layered struct implementing Layer. Read more

Composes this Layer with the given Subscriber, returning a Layered struct that implements Subscriber. Read more

Combines self with a Filter, returning a Filtered layer. 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

Performs the conversion.

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

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

Performs the conversion.

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.

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

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