Skip to content

Commit

Permalink
fix: add missing metrics and update to fixed libp2p
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jun 19, 2022
1 parent 684e6d9 commit 0f4f467
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ members = [
]

[patch.crates-io]
# TODO: switch to crates.io once 0.45 is released
libp2p = { git = "https://github.com/dignifiedquire/rust-libp2p", branch = "feat-kad-count" }
# libp2p = { path = "../rust-libp2p" }
4 changes: 2 additions & 2 deletions iroh-bitswap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tokio = { version = "1.0", features = ["sync"] }
bytes = "1.1.0"
cid = "0.8.0"
futures = "0.3.5"
libp2p = { version = "0.45", default-features = false }
libp2p = { version = "0.46", default-features = false }
multihash = "0.16.0"
prost = "0.10"
thiserror = "1.0.20"
Expand All @@ -31,7 +31,7 @@ git-version = "0.3.5"
[dev-dependencies]
criterion = "0.3.5"
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
libp2p = { version = "0.45", features = ["yamux", "noise", "tcp-tokio"], default-features = false }
libp2p = { version = "0.46", features = ["yamux", "noise", "tcp-tokio"], default-features = false }
tokio = { version = "1.0", features = ["macros", "net", "rt"] }
tokio-util = { version = "0.7", features = ["compat"] }

Expand Down
2 changes: 1 addition & 1 deletion iroh-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ time = "0.3.9"
headers = "0.3.7"
iroh-rpc-client = { path = "../iroh-rpc-client" }
hyper = "0.14.19"
libp2p = "0.45.0"
libp2p = "0.46.0"
iroh-util = { path = "../iroh-util" }
anyhow = "1"
futures = "0.3.5"
Expand Down
2 changes: 1 addition & 1 deletion iroh-p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async-stream = "0.3.3"
tempfile = "3.3.0"

[dependencies.libp2p]
version = "0.45"
version = "0.46"
default-features = false
features = [
"gossipsub",
Expand Down
1 change: 0 additions & 1 deletion iroh-p2p/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ impl DiskStorage {
}
}
counts.sort_unstable();
dbg!(&counts);
Ok(counts.last().map(|c| c + 1).unwrap_or_default())
}

Expand Down
5 changes: 1 addition & 4 deletions iroh-p2p/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use clap::Parser;
use iroh_p2p::config::{Libp2pConfig, CONFIG_FILE_NAME, ENV_PREFIX};
use iroh_p2p::{metrics, DiskStorage, Keychain, Libp2pService};
use iroh_util::{iroh_home_path, make_config};
use libp2p::metrics::Metrics;
use prometheus_client::registry::Registry;
use tokio::task;
use tracing::error;
Expand Down Expand Up @@ -50,14 +49,12 @@ async fn main() -> anyhow::Result<()> {
.unwrap();

let mut prom_registry = Registry::default();
let libp2p_metrics = Metrics::new(&mut prom_registry);
let metrics_config =
metrics::metrics_config_with_compile_time_info(network_config.metrics.clone());
iroh_metrics::init_tracer(metrics_config.clone()).expect("failed to initialize tracer");

let kc = Keychain::<DiskStorage>::new().await?;
let mut p2p_service =
Libp2pService::new(network_config, kc, &mut prom_registry, libp2p_metrics).await?;
let mut p2p_service = Libp2pService::new(network_config, kc, &mut prom_registry).await?;

let metrics_handle = iroh_metrics::MetricsHandle::from_registry(metrics_config, prom_registry)
.await
Expand Down
13 changes: 9 additions & 4 deletions iroh-p2p/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ impl<KeyStorage: Storage> Libp2pService<KeyStorage> {
config: Libp2pConfig,
mut keychain: Keychain<KeyStorage>,
registry: &mut Registry,
metrics: Metrics,
) -> Result<Self> {
let metrics = Metrics::new(registry);

let (network_sender_in, network_receiver_in) = channel(1_000); // TODO: configurable

tokio::spawn(async move {
Expand Down Expand Up @@ -339,6 +340,12 @@ impl<KeyStorage: Storage> Libp2pService<KeyStorage> {
Event::Ping(e) => {
self.metrics.record(&e);
}
Event::Relay(e) => {
self.metrics.record(&e);
}
Event::Dcutr(e) => {
self.metrics.record(&e);
}
_ => {
// TODO: check all important events are handled
}
Expand Down Expand Up @@ -527,14 +534,12 @@ mod tests {
#[tokio::test]
async fn test_fetch_providers() -> Result<()> {
let mut prom_registry = Registry::default();
let libp2p_metrics = Metrics::new(&mut prom_registry);
let mut network_config = Libp2pConfig::default();
network_config.metrics.debug = true;
let metrics_config = network_config.metrics.clone();

let kc = Keychain::<MemoryStorage>::new();
let mut p2p_service =
Libp2pService::new(network_config, kc, &mut prom_registry, libp2p_metrics).await?;
let mut p2p_service = Libp2pService::new(network_config, kc, &mut prom_registry).await?;

let metrics_handle = iroh_metrics::MetricsHandle::from_registry_with_tracer(
metrics::metrics_config_with_compile_time_info(metrics_config),
Expand Down
2 changes: 1 addition & 1 deletion iroh-rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tonic-health = "0.6.0"
prost = "0.10.3"
anyhow = "1.0.57"
bytes = "1.1.0"
libp2p = "0.45.0"
libp2p = "0.46.0"
iroh-metrics = { path = "../iroh-metrics" }
tracing = "0.1.34"
toml = "0.5.9"
Expand Down

0 comments on commit 0f4f467

Please sign in to comment.