pub fn scrape_once(&mut self) -> Vec<TimestampedUpdate> {
        let now = SYSTEM_TIME();
        let timestamp = now::to_datetime(now);

        let metric_fams = self.registry.gather();

        let mut out = vec![];

        let (value_readings, meta_value) =
            convert_metrics_to_value_rows(timestamp, metric_fams.iter());
        add_expiring_update(
            &MZ_PROMETHEUS_READINGS,
            value_readings,
            self.retain_for,
            &mut out,
        );

        let (histo_readings, meta_histo) =
            convert_metrics_to_histogram_rows(timestamp, metric_fams.iter());
        add_expiring_update(
            &MZ_PROMETHEUS_HISTOGRAMS,
            histo_readings,
            self.retain_for,
            &mut out,
        );

        // Find any metric metadata we need to add:
        let retain_for = self.retain_for;
        let missing = meta_value
            .into_iter()
            .chain(meta_histo.into_iter())
            .filter(|metric| {
                self.metadata
                    .insert(metric.clone(), now + retain_for)
                    .is_none()
            });
        add_metadata_update(missing, 1, retain_for, &mut out);

        // Expire any that can now go (I would love HashMap.drain_filter here):
        add_metadata_update(
            self.metadata
                .iter()
                .filter(|(_, &retention)| retention <= now)
                .map(|(row, _)| row)
                .cloned(),
            -1,
            retain_for,
            &mut out,
        );
        self.metadata.retain(|_, &mut retention| retention > now);

        out
    }
/// Scrapes the metrics once, producing a batch of updates that should be
/// inserted into the `mz_metrics` table.
Scrapes the metrics once, producing a batch of updates that should be
inserted into the `mz_metrics` table.
Scrapes the metrics once producing a batch of updates that should be inserted into the ` mz_metrics ` table .
pub fn scrape_once(&mut self) -> Vec<TimestampedUpdate> {
        let now = SYSTEM_TIME();
        let timestamp = now::to_datetime(now);
        let metric_fams = self.registry.gather();
        let mut out = vec![];
        let (value_readings, meta_value) =
            convert_metrics_to_value_rows(timestamp, metric_fams.iter());
        add_expiring_update(
            &MZ_PROMETHEUS_READINGS,
            value_readings,
            self.retain_for,
            &mut out,
        );
        let (histo_readings, meta_histo) =
            convert_metrics_to_histogram_rows(timestamp, metric_fams.iter());
        add_expiring_update(
            &MZ_PROMETHEUS_HISTOGRAMS,
            histo_readings,
            self.retain_for,
            &mut out,
        );
        // Find any metric metadata we need to add:
        let retain_for = self.retain_for;
        let missing = meta_value
            .into_iter()
            .chain(meta_histo.into_iter())
            .filter(|metric| {
                self.metadata
                    .insert(metric.clone(), now + retain_for)
                    .is_none()
            });
        add_metadata_update(missing, 1, retain_for, &mut out);
        // Expire any that can now go (I would love HashMap.drain_filter here):
        add_metadata_update(
            self.metadata
                .iter()
                .filter(|(_, &retention)| retention <= now)
                .map(|(row, _)| row)
                .cloned(),
            -1,
            retain_for,
            &mut out,
        );
        self.metadata.retain(|_, &mut retention| retention > now);
        out
    }
pub fn scrape_once ( & mut self ) -> Vec < TimestampedUpdate > { let now = SYSTEM_TIME ( ) ; let timestamp = now :: to_datetime ( now ) ; let metric_fams = self . registry . gather ( ) ; let mut out = vec ! [ ] ; let ( value_readings , meta_value ) = convert_metrics_to_value_rows ( timestamp , metric_fams . iter ( ) ) ; add_expiring_update ( & MZ_PROMETHEUS_READINGS , value_readings , self . retain_for , & mut out , ) ; let ( histo_readings , meta_histo ) = convert_metrics_to_histogram_rows ( timestamp , metric_fams . iter ( ) ) ; add_expiring_update ( & MZ_PROMETHEUS_HISTOGRAMS , histo_readings , self . retain_for , & mut out , ) ; // Find any metric metadata we need to add: let retain_for = self . retain_for ; let missing = meta_value . into_iter ( ) . chain ( meta_histo . into_iter ( ) ) . filter ( | metric | { self . metadata . insert ( metric . clone ( ) , now + retain_for ) . is_none ( ) } ) ; add_metadata_update ( missing , 1 , retain_for , & mut out ) ; // Expire any that can now go (I would love HashMap.drain_filter here): add_metadata_update ( self . metadata . iter ( ) . filter ( | ( _ , & retention ) | retention <= now ) . map ( | ( row , _ ) | row ) . cloned ( ) , - 1 , retain_for , & mut out , ) ; self . metadata . retain ( | _ , & mut retention | retention > now ) ; out }
Scrapes the metrics once, producing a batch of updates that should be
inserted into the `mz_metrics` table.
Scrapes the metrics once producing a batch of updates that should be inserted into the ` mz_metrics ` table .
&mut self
&mut self