xref: /aosp_15_r20/external/crosvm/vendor/generic/metrics/src/periodic_logger.rs (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1 // Copyright 2022 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 use std::result::Result;
6 use std::time::Duration;
7 
8 use metrics_events::MetricEventType;
9 
10 /// A logging struct meant for use in tracking and periodically
11 /// logging a single metric. The metric is aggregated over the
12 /// designated time period. Intended for use with high-frequency metrics.
13 pub struct PeriodicLogger;
14 
15 impl PeriodicLogger {
new(_event: MetricEventType, _period: Duration) -> Result<PeriodicLogger, String>16     pub fn new(_event: MetricEventType, _period: Duration) -> Result<PeriodicLogger, String> {
17         Ok(PeriodicLogger)
18     }
19 
20     /// Indicate the event has occurred with the given
21     /// value to be aggregated over the given time period.
log(&self, _value: i64)22     pub fn log(&self, _value: i64) {}
23 }
24