From faae09b29444615ed077c399a2f432590c473a9b Mon Sep 17 00:00:00 2001 From: wkargul Date: Thu, 10 Feb 2022 16:27:22 +0100 Subject: [PATCH 1/2] net metrics impl --- core/net/src/hybrid/service.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/net/src/hybrid/service.rs b/core/net/src/hybrid/service.rs index e0a351363..94073fc60 100644 --- a/core/net/src/hybrid/service.rs +++ b/core/net/src/hybrid/service.rs @@ -13,6 +13,7 @@ use anyhow::{anyhow, Context as AnyhowContext}; use futures::channel::mpsc; use futures::stream::LocalBoxStream; use futures::{FutureExt, SinkExt, Stream, StreamExt, TryStreamExt}; +use metrics::counter; use tokio::time; use url::Url; @@ -96,6 +97,9 @@ pub async fn start_network( default_id: NodeId, ids: Vec, ) -> anyhow::Result<()> { + counter!("net.connections.p2p", 0); + counter!("net.connections.relay", 0); + let url = Url::parse(&format!( "udp://{}", relay_addr(&config) @@ -175,6 +179,9 @@ pub async fn start_network( if let Some(address) = client.public_addr().await { log::info!("Public address: {}", address); + counter!("net.public-addresses", 1); + } else { + counter!("net.public-addresses", 0); } Ok(()) @@ -715,6 +722,12 @@ impl State { client.forward_unreliable(remote_id).await?.into() }; + if client.sessions.has_p2p_connection(remote_id).await { + counter!("net.connections.p2p", 1) + } else { + counter!("net.connections.relay", 1) + }; + let mut inner = self.inner.borrow_mut(); inner.forward.insert((remote_id, reliable), forward.clone()); From b0d420dd705044d9a6ce2a2c0bff0ebf80f79cf7 Mon Sep 17 00:00:00 2001 From: wkargul Date: Fri, 11 Feb 2022 09:59:05 +0100 Subject: [PATCH 2/2] `ya-relay` commit rev update --- Cargo.lock | 8 ++++---- core/net/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d51aa843..086a5263a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7292,7 +7292,7 @@ dependencies = [ [[package]] name = "ya-relay-client" version = "0.1.0" -source = "git+https://github.com/golemfactory/ya-relay.git?rev=b823121f7ec604e9047ec5c4bb0f11895210db56#b823121f7ec604e9047ec5c4bb0f11895210db56" +source = "git+https://github.com/golemfactory/ya-relay.git?rev=e6a32833cb3f4219580cb998f966d051158d4f4d#e6a32833cb3f4219580cb998f966d051158d4f4d" dependencies = [ "anyhow", "chrono", @@ -7310,7 +7310,7 @@ dependencies = [ [[package]] name = "ya-relay-core" version = "0.1.0" -source = "git+https://github.com/golemfactory/ya-relay.git?rev=b823121f7ec604e9047ec5c4bb0f11895210db56#b823121f7ec604e9047ec5c4bb0f11895210db56" +source = "git+https://github.com/golemfactory/ya-relay.git?rev=e6a32833cb3f4219580cb998f966d051158d4f4d#e6a32833cb3f4219580cb998f966d051158d4f4d" dependencies = [ "anyhow", "chrono", @@ -7338,7 +7338,7 @@ dependencies = [ [[package]] name = "ya-relay-proto" version = "0.1.0" -source = "git+https://github.com/golemfactory/ya-relay.git?rev=b823121f7ec604e9047ec5c4bb0f11895210db56#b823121f7ec604e9047ec5c4bb0f11895210db56" +source = "git+https://github.com/golemfactory/ya-relay.git?rev=e6a32833cb3f4219580cb998f966d051158d4f4d#e6a32833cb3f4219580cb998f966d051158d4f4d" dependencies = [ "anyhow", "bytes 0.5.6", @@ -7355,7 +7355,7 @@ dependencies = [ [[package]] name = "ya-relay-stack" version = "0.1.0" -source = "git+https://github.com/golemfactory/ya-relay.git?rev=b823121f7ec604e9047ec5c4bb0f11895210db56#b823121f7ec604e9047ec5c4bb0f11895210db56" +source = "git+https://github.com/golemfactory/ya-relay.git?rev=e6a32833cb3f4219580cb998f966d051158d4f4d#e6a32833cb3f4219580cb998f966d051158d4f4d" dependencies = [ "derive_more", "futures 0.3.13", diff --git a/core/net/Cargo.toml b/core/net/Cargo.toml index 1396ccd99..89807a0f1 100644 --- a/core/net/Cargo.toml +++ b/core/net/Cargo.toml @@ -13,7 +13,7 @@ hybrid-net = [] [dependencies] ya-core-model = { version = "^0.5", features=["net", "identity"] } -ya-relay-client = { git = "https://github.com/golemfactory/ya-relay.git", rev = "b823121f7ec604e9047ec5c4bb0f11895210db56" } +ya-relay-client = { git = "https://github.com/golemfactory/ya-relay.git", rev = "e6a32833cb3f4219580cb998f966d051158d4f4d" } #ya-relay-client = { path = "../../../ya-relay/client" } ya-sb-proto = { version = "0.4" }