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
impl Pretty
Sourcepub fn new() -> Self
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().
Sourcepub fn sampler(
self,
sampler: impl Fn(&Span) -> bool + Send + Sync + 'static,
) -> Self
pub fn sampler( self, sampler: impl Fn(&Span) -> bool + Send + Sync + 'static, ) -> Self
Exports only the spans sampler accepts.
PHP: the $sampler argument.
Sourcepub fn max_trace_frames(self, frames: usize) -> Self
pub fn max_trace_frames(self, frames: usize) -> Self
Prints at most frames stack frames of an error.
PHP: the $maxTraceFrames argument.
Sourcepub fn width(self, width: usize) -> Self
pub fn width(self, width: usize) -> Self
The width of the separator line, in columns.
PHP: the $width argument.