1// Copyright 2019 The Fuchsia Authors
2//
3// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
4// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
5// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
6// This file may not be copied, modified, or distributed except according to
7// those terms.
89use crate::metrics::{Metrics, MetricsReporter};
10use anyhow::Error;
11use tracing::info;
1213/// A stub implementation of MetricsReporter which only log metrics.
14#[derive(Debug)]
15pub struct StubMetricsReporter;
1617impl MetricsReporter for StubMetricsReporter {
18fn report_metrics(&mut self, metrics: Metrics) -> Result<(), Error> {
19info!("Received request to report metrics: {:?}", metrics);
20Ok(())
21 }
22}
2324#[cfg(test)]
25mod tests {
26use super::*;
27use std::time::Duration;
2829#[test]
30fn test_stub_metrics_reporter() {
31let mut stub = StubMetricsReporter;
32let result = stub.report_metrics(Metrics::UpdateCheckResponseTime {
33 response_time: Duration::from_secs(2),
34 successful: true,
35 });
36assert!(result.is_ok(), "{result:?}");
37 }
38}