Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move metrics init into CLI #2135

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions iroh-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ nix = { version = "0.27", features = ["signal", "process"] }
regex = "1.10.3"
testdir = "0.9.1"
walkdir = "2"

[features]
default = ["metrics"]
metrics = []
10 changes: 10 additions & 0 deletions iroh-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ pub(crate) enum Commands {

impl Cli {
pub(crate) async fn run(self, data_dir: &Path) -> Result<()> {

// Initialize the metrics collection.
//
// The metrics are global per process. Subsequent calls do not change the metrics
// collection and will return an error. We ignore this error. This means that if you'd
// spawn multiple Iroh nodes in the same process, the metrics would be shared between the
// nodes.
#[cfg(feature = "metrics")]
iroh::metrics::try_init_metrics_collection().ok();

match self.command {
Commands::Console => {
let env = ConsoleEnv::for_console(data_dir)?;
Expand Down
9 changes: 0 additions & 9 deletions iroh/src/node/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,6 @@ where
trace!("spawning node");
let lp = LocalPoolHandle::new(num_cpus::get());

// Initialize the metrics collection.
//
// The metrics are global per process. Subsequent calls do not change the metrics
// collection and will return an error. We ignore this error. This means that if you'd
// spawn multiple Iroh nodes in the same process, the metrics would be shared between the
// nodes.
#[cfg(feature = "metrics")]
crate::metrics::try_init_metrics_collection().ok();

let mut transport_config = quinn::TransportConfig::default();
transport_config
.max_concurrent_bidi_streams(MAX_STREAMS.try_into()?)
Expand Down
Loading