Skip to content

Commit

Permalink
Merge pull request #1835 from golemfactory/wkargul/net-metrics
Browse files Browse the repository at this point in the history
Hybrid NET metrics implemented:
- `net.connections.p2p`
- `net.connections.relay`
- `net.public-addresses`

`ya-realy` commit revision updated.
  • Loading branch information
wkargul authored Feb 11, 2022
2 parents 5f54ba3 + b0d420d commit f9e0b37
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
13 changes: 13 additions & 0 deletions core/net/src/hybrid/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -96,6 +97,9 @@ pub async fn start_network(
default_id: NodeId,
ids: Vec<NodeId>,
) -> anyhow::Result<()> {
counter!("net.connections.p2p", 0);
counter!("net.connections.relay", 0);

let url = Url::parse(&format!(
"udp://{}",
relay_addr(&config)
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -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());

Expand Down

0 comments on commit f9e0b37

Please sign in to comment.