metrics_runtime/
control.rs1use crate::{
2 data::Snapshot,
3 registry::{MetricRegistry, ScopeRegistry},
4};
5
6use metrics_core::{Observe, Observer};
7
8use std::sync::Arc;
9
10#[derive(Clone)]
17pub struct Controller {
18 metric_registry: Arc<MetricRegistry>,
19 scope_registry: Arc<ScopeRegistry>,
20}
21
22impl Controller {
23 pub(crate) fn new(
24 metric_registry: Arc<MetricRegistry>,
25 scope_registry: Arc<ScopeRegistry>,
26 ) -> Controller {
27 Controller {
28 metric_registry,
29 scope_registry,
30 }
31 }
32
33 pub fn snapshot(&self) -> Snapshot {
35 self.metric_registry.snapshot()
36 }
37}
38
39impl Observe for Controller {
40 fn observe<O: Observer>(&self, observer: &mut O) {
41 self.metric_registry.observe(observer)
42 }
43}