[−][src]Struct tracing_flame::FlameLayer
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
impl<S, W> FlameLayer<S, W> where
S: Subscriber + for<'span> LookupSpan<'span>,
W: Write + 'static,
[src]
S: Subscriber + for<'span> LookupSpan<'span>,
W: Write + 'static,
pub fn new(writer: W) -> Self
[src]
Returns a new FlameLayer
that outputs all folded stack samples to the
provided writer.
pub fn flush_on_drop(&self) -> FlushGuard<W>
[src]
Returns a FlushGuard
which will flush the FlameLayer
's writer when
it is dropped, or when flush
is manually invoked on the guard.
pub fn with_empty_samples(self, enabled: bool) -> Self
[src]
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.
pub fn with_threads_collapsed(self, enabled: bool) -> Self
[src]
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.
impl<S> FlameLayer<S, BufWriter<File>> where
S: Subscriber + for<'span> LookupSpan<'span>,
[src]
S: Subscriber + for<'span> LookupSpan<'span>,
pub fn with_file(
path: impl AsRef<Path>
) -> Result<(Self, FlushGuard<BufWriter<File>>), Error>
[src]
path: impl AsRef<Path>
) -> Result<(Self, FlushGuard<BufWriter<File>>), Error>
Constructs a FlameLayer
that outputs to a BufWriter
to the given path, and a
FlushGuard
to ensure the writer is flushed.
Trait Implementations
impl<S: Debug, W: Debug> Debug for FlameLayer<S, W>
[src]
impl<S, W> Layer<S> for FlameLayer<S, W> where
S: Subscriber + for<'span> LookupSpan<'span>,
W: Write + 'static,
[src]
S: Subscriber + for<'span> LookupSpan<'span>,
W: Write + 'static,
fn on_enter(&self, id: &Id, ctx: Context<S>)
[src]
fn on_exit(&self, id: &Id, ctx: Context<S>)
[src]
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
[src]
fn enabled(&self, metadata: &Metadata, ctx: Context<S>) -> bool
[src]
fn new_span(&self, attrs: &Attributes, id: &Id, ctx: Context<S>)
[src]
fn on_record(&self, _span: &Id, _values: &Record, _ctx: Context<S>)
[src]
fn on_follows_from(&self, _span: &Id, _follows: &Id, _ctx: Context<S>)
[src]
fn on_event(&self, _event: &Event, _ctx: Context<S>)
[src]
fn on_close(&self, _id: Id, _ctx: Context<S>)
[src]
fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<S>)
[src]
fn and_then<L>(self, layer: L) -> Layered<L, Self, S> where
L: Layer<S>,
[src]
L: Layer<S>,
fn with_subscriber(self, inner: S) -> Layered<Self, S, S>
[src]
Auto Trait Implementations
impl<S, W> RefUnwindSafe for FlameLayer<S, W> where
S: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, W> Send for FlameLayer<S, W> where
S: Send,
W: Send,
S: Send,
W: Send,
impl<S, W> Sync for FlameLayer<S, W> where
S: Sync,
W: Send,
S: Sync,
W: Send,
impl<S, W> Unpin for FlameLayer<S, W> where
S: Unpin,
S: Unpin,
impl<S, W> UnwindSafe for FlameLayer<S, W> where
S: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,