pub struct TelemetryPipe { /* private fields */ }Expand description
A running telemetry pipe. Created by OfflineProtocol::enable_telemetry
and stopped by disable_telemetry or by being dropped.
Implementations§
Source§impl TelemetryPipe
impl TelemetryPipe
Sourcepub fn set_enabled(&self, enabled: bool)
pub fn set_enabled(&self, enabled: bool)
Stops or resumes collection. Off, an emit costs one atomic load and nothing is buffered; what is already queued still drains.
Resuming restamps the summary anchor. The duration is the one summary
field derived from a clock rather than accumulated from records, so
unlike every counter it keeps growing while collection is off, and the
first row afterwards would otherwise bill the entire opt-out. Only the
off-to-on edge does this, so repeated set_enabled(true) calls on a
live pipe do not keep resetting the span.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether collection is on.
Sourcepub fn flush_blocking(&self, budget: Duration) -> bool
pub fn flush_blocking(&self, budget: Duration) -> bool
Flushes and waits up to budget for the uploader to finish the
cycle. Returns whether it finished in time.
Sourcepub fn stats(&self) -> TelemetryStats
pub fn stats(&self) -> TelemetryStats
A snapshot of the counters.
Sourcepub fn end_session(&self)
pub fn end_session(&self)
Closes the current session: summary, a blocking flush within
FINAL_FLUSH_BUDGET, then a fresh session id.
A no-op while collection is off, for the reason given on
Self::notify_app_state. Self::flush is the call that pushes a
queued backlog without collecting anything new.
Sourcepub fn notify_app_state(&self, state: AppState)
pub fn notify_app_state(&self, state: AppState)
Reports an application lifecycle transition.
While collection is off the transition is recorded but nothing is
emitted. A session summary is collection: it is a row the ingest
stores and bills, carrying the session duration and every counter the
pairer accumulated, so emitting one for a user who switched telemetry
off would break the promise docs/telemetry.md makes for that switch.
The edge is still tracked, so the next foreground after collection
resumes rotates the session rather than being read as a non-edge.
Sourcepub fn stop(&self, budget: Duration) -> bool
pub fn stop(&self, budget: Duration) -> bool
Stops the uploader after one final flush, waiting up to budget for
the thread to exit before detaching it. Idempotent.
Sourcepub fn is_stopped(&self) -> bool
pub fn is_stopped(&self) -> bool
Whether stop has run.
Sourcepub fn is_durable(&self) -> bool
pub fn is_durable(&self) -> bool
Whether the batch queue is mirrored to storage.
Reads an atomic rather than the store mutex, which the uploader holds across a request: a caller asking a question about configuration must not be parked behind a fifteen-second socket timeout.
Trait Implementations§
Source§impl Debug for TelemetryPipe
impl Debug for TelemetryPipe
Source§impl Drop for TelemetryPipe
impl Drop for TelemetryPipe
Source§fn drop(&mut self)
fn drop(&mut self)
Signals the final flush and detaches the worker without waiting for it.
The flush still happens, bounded by FINAL_FLUSH_BUDGET on the
worker’s own thread; what the dropping thread does not do is block for
it. A drop lands wherever the last handle happens to be released, and
on the mobile bindings that is a teardown path: iOS releases native
modules on the main thread during a bridge reload, so waiting here put
three seconds inside the scene-update watchdog’s window. A caller that
needs to observe the flush calls Self::stop with a budget first,
which is what disable_telemetry does.
An inline pipe is the exception, and only because it has to be: with no worker there is no other thread to run the flush on, so the dropping thread is the only one that can. That configuration is the tests and the benches, never a shipped binary.
Auto Trait Implementations§
impl !Freeze for TelemetryPipe
impl !RefUnwindSafe for TelemetryPipe
impl !UnwindSafe for TelemetryPipe
impl Send for TelemetryPipe
impl Sync for TelemetryPipe
impl Unpin for TelemetryPipe
impl UnsafeUnpin for TelemetryPipe
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);