Add support for sourced metrics. (#6895)

* Add support for sourced metrics.

A sourced metric is a metric that obtains its values
from an existing source, rather than the values being
independently recorded. It thus allows collecting
metrics from existing counters or gauges without
having to duplicate them in a dedicated prometheus
counter or gauge (and hence another atomic value).

The first use-case is to feed the bandwidth counters
from libp2p directly into prometheus.

* Tabs, not spaces.

* Tweak bandwidth counter registration.

* Add debug assertion for variable labels and values.

* Document monotonicity requirement for sourced counters.

* CI

* Update client/network/src/service.rs

Co-authored-by: Max Inden <mail@max-inden.de>

Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
Roman Borschel
2020-08-18 07:59:32 +02:00
committed by GitHub
parent 74a583d147
commit 807329ddb8
3 changed files with 187 additions and 18 deletions
+3
View File
@@ -31,6 +31,9 @@ use std::net::SocketAddr;
#[cfg(not(target_os = "unknown"))]
mod networking;
mod sourced;
pub use sourced::{SourcedCounter, SourcedGauge, MetricSource};
#[cfg(target_os = "unknown")]
pub use unknown_os::init_prometheus;