Fix the metered unbounded sender/recievers (#6246)

* Fix the metered unbounded sender/recievers

* Use a counter instead

* Update client/rpc/src/system/tests.rs

* Add an is_terminated check

* Add FusedStream impl

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Ashley
2020-06-06 13:06:22 +02:00
committed by GitHub
parent 7c051caa42
commit 84cdb02963
5 changed files with 41 additions and 23 deletions
+5 -5
View File
@@ -23,8 +23,8 @@ use prometheus::{
core::{ AtomicU64, GenericGauge, GenericCounter },
};
#[cfg(features = "metered")]
use prometheus::{core::GenericGaugeVec, Opts};
#[cfg(feature = "metered")]
use prometheus::{core::GenericCounterVec, Opts};
lazy_static! {
@@ -37,9 +37,9 @@ lazy_static! {
).expect("Creating of statics doesn't fail. qed");
}
#[cfg(features = "metered")]
#[cfg(feature = "metered")]
lazy_static! {
pub static ref UNBOUNDED_CHANNELS_COUNTER : GenericGaugeVec<AtomicU64> = GenericGaugeVec::new(
pub static ref UNBOUNDED_CHANNELS_COUNTER : GenericCounterVec<AtomicU64> = GenericCounterVec::new(
Opts::new("unbounded_channel_len", "Items in each mpsc::unbounded instance"),
&["entity", "action"] // 'name of channel, send|received|dropped
).expect("Creating of statics doesn't fail. qed");
@@ -52,7 +52,7 @@ pub fn register_globals(registry: &Registry) -> Result<(), PrometheusError> {
registry.register(Box::new(TOKIO_THREADS_ALIVE.clone()))?;
registry.register(Box::new(TOKIO_THREADS_TOTAL.clone()))?;
#[cfg(features = "metered")]
#[cfg(feature = "metered")]
registry.register(Box::new(UNBOUNDED_CHANNELS_COUNTER.clone()))?;
Ok(())