pub fn encode_histogram(
        &mut self,
        name: &str,
        buckets: impl Iterator<Item = (f64, f64)>,
        sum: f64,
        help: &str,
    ) -> io::Result<()> {
        self.encode_header(name, help, "histogram")?;
        let mut total: f64 = 0.0;
        let mut saw_infinity = false;
        for (bucket, v) in buckets {
            total += v;
            if bucket == std::f64::INFINITY {
                saw_infinity = true;
                writeln!(
                    self.writer,
                    "{}_bucket{{le=\"+Inf\"}} {} {}",
                    name, total, self.now_millis
                )?;
            } else {
                writeln!(
                    self.writer,
                    "{}_bucket{{le=\"{}\"}} {} {}",
                    name, bucket, total, self.now_millis
                )?;
            }
        }
        if !saw_infinity {
            writeln!(
                self.writer,
                "{}_bucket{{le=\"+Inf\"}} {} {}",
                name, total, self.now_millis
            )?;
        }
        writeln!(self.writer, "{}_sum {} {}", name, sum, self.now_millis)?;
        writeln!(self.writer, "{}_count {} {}", name, total, self.now_millis)
    }
/// Encodes the metadata and the value of a histogram.
///
/// SUM is the sum of all observed values, before they were put
/// into buckets.
///
/// BUCKETS is a list (key, value) pairs, where KEY is the bucket
/// and VALUE is the number of items *in* this bucket (i.e., it's
/// not a cumulative value).
Encodes the metadata and the value of a histogram.
SUM is the sum of all observed values, before they were put
into buckets.

BUCKETS is a list (key, value) pairs, where KEY is the bucket
and VALUE is the number of items *in* this bucket .
Encodes the metadata and the value of a histogram . SUM is the sum of all observed values before they were put into buckets . BUCKETS is a list ( key value ) pairs where KEY is the bucket and VALUE is the number of items * in * this bucket .
pub fn encode_histogram(
        &mut self,
        name: &str,
        buckets: impl Iterator<Item = (f64, f64)>,
        sum: f64,
        help: &str,
    ) -> io::Result<()> {
        self.encode_header(name, help, "histogram")?;
        let mut total: f64 = 0.0;
        let mut saw_infinity = false;
        for (bucket, v) in buckets {
            total += v;
            if bucket == std::f64::INFINITY {
                saw_infinity = true;
                writeln!(
                    self.writer,
                    "{}_bucket{{le=\"+Inf\"}} {} {}",
                    name, total, self.now_millis
                )?;
            } else {
                writeln!(
                    self.writer,
                    "{}_bucket{{le=\"{}\"}} {} {}",
                    name, bucket, total, self.now_millis
                )?;
            }
        }
        if !saw_infinity {
            writeln!(
                self.writer,
                "{}_bucket{{le=\"+Inf\"}} {} {}",
                name, total, self.now_millis
            )?;
        }
        writeln!(self.writer, "{}_sum {} {}", name, sum, self.now_millis)?;
        writeln!(self.writer, "{}_count {} {}", name, total, self.now_millis)
    }
pub fn encode_histogram ( & mut self , name : & str , buckets : impl Iterator < Item = ( f64 , f64 ) > , sum : f64 , help : & str , ) -> io :: Result < ( ) > { self . encode_header ( name , help , " " ) ? ; let mut total : f64 = 0.0 ; let mut saw_infinity = false ; for ( bucket , v ) in buckets { total += v ; if bucket == std :: f64 :: INFINITY { saw_infinity = true ; writeln ! ( self writer " \" \" " name total self now_millis ) ? ; } else { writeln ! ( self writer " \" \" " name bucket total self now_millis ) ? ; } } if ! saw_infinity { writeln ! ( self writer " \" \" " name total self now_millis ) ? ; } writeln ! ( self writer " " name sum self now_millis ) ? ; writeln ! ( self writer " " name total self now_millis ) }
Encodes the metadata and the value of a histogram.
Encodes the metadata and the value of a histogram .
&mut self
name
&str
buckets
impl Iterator<Item = (f64, f64)>
sum
f64
help
&str
&mut self
name
&str
buckets
impl Iterator<Item = (f64, f64)>
sum
f64
help
&str