Skip to main content

Pretty

Struct Pretty 

Source
pub struct Pretty { /* private fields */ }
Expand description

Writes each span as a coloured block for local development: a header (action, duration, short trace id), the attributes other than span.* aligned in a column with level first, the error with at most max_trace_frames stack frames, and a separator line width wide. Spans with an error go to standard error, the others to standard output.

PHP: Utopia\Span\Exporter\Pretty.

use utopia_span::{Pretty, Span};

let span = Span::new("db.query");
span.set("span.duration", 0.0123).set("rows", 3);
let text = String::from_utf8(Pretty::new().width(10).render(&span)).unwrap();
assert!(text.contains("12.3ms"));
assert!(text.contains("rows"));
use Utopia\Span\Exporter\Pretty;
use Utopia\Span\Span;

$span = new Span('db.query');
$span->set('span.duration', 0.0123)->set('rows', 3);
(new Pretty(width: 10))->export($span); // db.query · 12.3ms · … then "rows 3"

Implementations§

Source§

impl Pretty

Source

pub fn new() -> Self

An exporter of every span, with at most 3 stack frames per error and a 60 columns wide separator, writing to the process’s standard output and error.

PHP: new Pretty().

Source

pub fn sampler( self, sampler: impl Fn(&Span) -> bool + Send + Sync + 'static, ) -> Self

Exports only the spans sampler accepts.

PHP: the $sampler argument.

Source

pub fn max_trace_frames(self, frames: usize) -> Self

Prints at most frames stack frames of an error.

PHP: the $maxTraceFrames argument.

Source

pub fn width(self, width: usize) -> Self

The width of the separator line, in columns.

PHP: the $width argument.

Source

pub fn writers( self, out: Box<dyn Write + Send>, err: Box<dyn Write + Send>, ) -> Self

Writes spans to out, and spans with an error to err.

PHP: the $stdout and $stderr arguments.

Source

pub fn render(&self, span: &Span) -> Vec<u8> ⓘ

The text this exporter writes for span.

Trait Implementations§

Source§

impl Debug for Pretty

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Pretty

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Exporter for Pretty

Source§

fn sample(&self, span: &Span) -> bool

Whether to export span; false drops it. Read more
Source§

fn export(&self, span: &Span)

Exports a finished span. Called for spans Exporter::sample accepted. Read more

Auto Trait Implementations§

§

impl !Freeze for Pretty

§

impl !RefUnwindSafe for Pretty

§

impl !UnwindSafe for Pretty

§

impl Forget for Pretty

§

impl Move for Pretty

§

impl Send for Pretty

§

impl Sync for Pretty

§

impl Unpin for Pretty

§

impl UnsafeUnpin for Pretty

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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