Struct hdrhistogram::serialization::interval_log::IntervalLogWriter
source · pub struct IntervalLogWriter<'a, 'b, W: 'a + Write, S: 'b + Serializer> { /* private fields */ }
Expand description
Writes interval histograms in an interval log.
This isn’t created directly; start with an IntervalLogWriterBuilder
. Once you’ve written the
headers and ended up with an IntervalLogWriter
, typical usage would be to write a histogram
at regular intervals (e.g. once a second).
use hdrhistogram::serialization;
use hdrhistogram::serialization::interval_log;
let mut buf = Vec::new();
let mut serializer = serialization::V2Serializer::new();
// create a writer via a builder
let mut writer = interval_log::IntervalLogWriterBuilder::new()
.begin_log_with(&mut buf, &mut serializer)
.unwrap();
writer.write_comment("Comment 2").unwrap();
// .. write some intervals
Implementations§
source§impl<'a, 'b, W: 'a + Write, S: 'b + Serializer> IntervalLogWriter<'a, 'b, W, S>
impl<'a, 'b, W: 'a + Write, S: 'b + Serializer> IntervalLogWriter<'a, 'b, W, S>
sourcepub fn write_comment(&mut self, s: &str) -> Result<()>
pub fn write_comment(&mut self, s: &str) -> Result<()>
Write a comment line.
Comments containing ‘\n’ will be transformed into multiple lines of comments.
sourcepub fn write_histogram<T: Counter>(
&mut self,
h: &Histogram<T>,
start_timestamp: Duration,
duration: Duration,
tag: Option<Tag<'_>>,
) -> Result<(), IntervalLogWriterError<S::SerializeError>>
pub fn write_histogram<T: Counter>( &mut self, h: &Histogram<T>, start_timestamp: Duration, duration: Duration, tag: Option<Tag<'_>>, ) -> Result<(), IntervalLogWriterError<S::SerializeError>>
Write an interval histogram.
start_timestamp
is the time since the epoch in seconds that measurements started being
recorded in this interval. If you’re using a StartTime or BaseTime offset, you should
instead use a delta since that time. See the discussion about timestamps in the module-level
documentation.
duration
is the duration of the interval in seconds.
tag
is an optional tag for this histogram.