Loading Cargo.lock +1 −0 Original line number Diff line number Diff line Loading @@ -7012,6 +7012,7 @@ dependencies = [ "hex-literal", "httparse", "itertools 0.14.0", "metrics", "oneshot-fused-workaround", "percent-encoding", "postage", Loading crates/arti-relay/Cargo.toml +6 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,12 @@ full = [ "web-time-compat/full", ] metrics = ["dep:metrics-exporter-prometheus"] # This feature flag enables experimental features that are not supported. Turning it on may # void your API. experimental = ["metrics"] metrics = ["tor-chanmgr/metrics", "dep:metrics-exporter-prometheus", "__is_experimental"] __is_experimental = [] [dependencies] anyhow = "1.0.23" Loading crates/tor-chanmgr/Cargo.toml +2 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ repository = "https://gitlab.torproject.org/tpo/core/arti.git/" [features] default = [] experimental = ["experimental-api", "relay", "testing"] experimental = ["experimental-api", "relay", "metrics", "testing"] experimental-api = ["__is_experimental"] full = [ "pt-client", Loading Loading @@ -53,6 +53,7 @@ derive_more = { version = "2.0.1", features = ["full"] } educe = "0.4.22" futures = "0.3.14" httparse = "1.10" metrics = { version = "0.24.1", optional = true } oneshot-fused-workaround = { path = "../oneshot-fused-workaround", version = "0.6.0" } percent-encoding = "2.3.1" postage = { version = "0.5.0", default-features = false, features = ["futures-traits"] } Loading crates/tor-chanmgr/src/lib.rs +10 −1 Original line number Diff line number Diff line Loading @@ -319,7 +319,16 @@ impl<R: Runtime> ChanMgr<R> { src: Sensitive<std::net::SocketAddr>, stream: <R as tor_rtcompat::NetStreamProvider>::Stream, ) -> Result<Arc<Channel>> { self.mgr.handle_incoming(src, stream).await let result = self.mgr.handle_incoming(src, stream).await; #[cfg(feature = "metrics")] if result.is_ok() { self.mgr.metrics.channels_built_success.increment(1); } else { self.mgr.metrics.channels_built_failure.increment(1); } result } /// Try to get a suitable channel to the provided `target`, Loading crates/tor-chanmgr/src/mgr.rs +31 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,22 @@ pub(crate) struct AbstractChanMgr<CF: AbstractChannelFactory> { /// The memory quota account that every channel will be a child of pub(crate) memquota: ToplevelAccount, /// Metrics counters / gauges / histograms. #[cfg(feature = "metrics")] pub(crate) metrics: ChanMgrMetrics, } /// Struct to hold all the metrics counters / gauges / histograms we use. /// /// We create these and store them in the [`AbstractChanMgr`] in order to avoid /// the performance hit associated with re-registering counters. #[cfg(feature = "metrics")] pub(crate) struct ChanMgrMetrics { /// Number of channels successfully built. pub(crate) channels_built_success: metrics::Counter, /// Number of channels that we tried to build but had an error. pub(crate) channels_built_failure: metrics::Counter, } /// Type alias for a future that we wait on to see when a pending Loading Loading @@ -254,6 +270,21 @@ impl<CF: AbstractChannelFactory + Clone> AbstractChanMgr<CF> { channels: state::MgrState::new(connector, config, dormancy, netparams), reporter, memquota, #[cfg(feature = "metrics")] metrics: ChanMgrMetrics { channels_built_success: metrics::counter!( description: "Total number of channels built", unit: metrics::Unit::Count, "arti_chanmgr_channels_built", "result" => "success", ), channels_built_failure: metrics::counter!( description: "Total number of channels built", unit: metrics::Unit::Count, "arti_chanmgr_channels_built", "result" => "failure", ), }, } } Loading Loading
Cargo.lock +1 −0 Original line number Diff line number Diff line Loading @@ -7012,6 +7012,7 @@ dependencies = [ "hex-literal", "httparse", "itertools 0.14.0", "metrics", "oneshot-fused-workaround", "percent-encoding", "postage", Loading
crates/arti-relay/Cargo.toml +6 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,12 @@ full = [ "web-time-compat/full", ] metrics = ["dep:metrics-exporter-prometheus"] # This feature flag enables experimental features that are not supported. Turning it on may # void your API. experimental = ["metrics"] metrics = ["tor-chanmgr/metrics", "dep:metrics-exporter-prometheus", "__is_experimental"] __is_experimental = [] [dependencies] anyhow = "1.0.23" Loading
crates/tor-chanmgr/Cargo.toml +2 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ repository = "https://gitlab.torproject.org/tpo/core/arti.git/" [features] default = [] experimental = ["experimental-api", "relay", "testing"] experimental = ["experimental-api", "relay", "metrics", "testing"] experimental-api = ["__is_experimental"] full = [ "pt-client", Loading Loading @@ -53,6 +53,7 @@ derive_more = { version = "2.0.1", features = ["full"] } educe = "0.4.22" futures = "0.3.14" httparse = "1.10" metrics = { version = "0.24.1", optional = true } oneshot-fused-workaround = { path = "../oneshot-fused-workaround", version = "0.6.0" } percent-encoding = "2.3.1" postage = { version = "0.5.0", default-features = false, features = ["futures-traits"] } Loading
crates/tor-chanmgr/src/lib.rs +10 −1 Original line number Diff line number Diff line Loading @@ -319,7 +319,16 @@ impl<R: Runtime> ChanMgr<R> { src: Sensitive<std::net::SocketAddr>, stream: <R as tor_rtcompat::NetStreamProvider>::Stream, ) -> Result<Arc<Channel>> { self.mgr.handle_incoming(src, stream).await let result = self.mgr.handle_incoming(src, stream).await; #[cfg(feature = "metrics")] if result.is_ok() { self.mgr.metrics.channels_built_success.increment(1); } else { self.mgr.metrics.channels_built_failure.increment(1); } result } /// Try to get a suitable channel to the provided `target`, Loading
crates/tor-chanmgr/src/mgr.rs +31 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,22 @@ pub(crate) struct AbstractChanMgr<CF: AbstractChannelFactory> { /// The memory quota account that every channel will be a child of pub(crate) memquota: ToplevelAccount, /// Metrics counters / gauges / histograms. #[cfg(feature = "metrics")] pub(crate) metrics: ChanMgrMetrics, } /// Struct to hold all the metrics counters / gauges / histograms we use. /// /// We create these and store them in the [`AbstractChanMgr`] in order to avoid /// the performance hit associated with re-registering counters. #[cfg(feature = "metrics")] pub(crate) struct ChanMgrMetrics { /// Number of channels successfully built. pub(crate) channels_built_success: metrics::Counter, /// Number of channels that we tried to build but had an error. pub(crate) channels_built_failure: metrics::Counter, } /// Type alias for a future that we wait on to see when a pending Loading Loading @@ -254,6 +270,21 @@ impl<CF: AbstractChannelFactory + Clone> AbstractChanMgr<CF> { channels: state::MgrState::new(connector, config, dormancy, netparams), reporter, memquota, #[cfg(feature = "metrics")] metrics: ChanMgrMetrics { channels_built_success: metrics::counter!( description: "Total number of channels built", unit: metrics::Unit::Count, "arti_chanmgr_channels_built", "result" => "success", ), channels_built_failure: metrics::counter!( description: "Total number of channels built", unit: metrics::Unit::Count, "arti_chanmgr_channels_built", "result" => "failure", ), }, } } Loading