1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Shared internal building blocks for "lazy" metric types.
//!
//! It exists to reduce duplication between `LazyGauge` and `LazyCounter`
//! (and any future lazy metric types) by providing a common source abstraction.
//!
//! Note: the public API intentionally keeps `LazyGauge` / `LazyCounter` focused and does not
//! expose these internal traits.
use Arc;
/// Internal source of values for "lazy" metrics.
///
/// This trait is crate-private so other internal modules (e.g. `metrics::lazy_group`) can provide
/// alternative implementations (such as a scrape-scoped cached source) without exposing extra
/// public types.
///
/// Implementations must be thread-safe (`Send + Sync`) because metrics may be encoded from multiple
/// threads depending on the exporter design.
///
/// Implementations should be cheap to call; the encoder may call this during scrapes to obtain the
/// current value.
pub
/// A simple [`LazySource`] implementation backed by a closure.
///
/// This is used by `LazyGauge::new(...)` / `LazyCounter::new(...)` when the user provides a
/// fetcher.
pub