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

Take care of TOKIO_CONSOLE_BUFFER_CAPACITY and set it on Builder::with_default_env #568

Merged
merged 1 commit into from
Jul 5, 2024
Merged
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
15 changes: 15 additions & 0 deletions console-subscriber/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ impl Builder {
self.recording_path = Some(path.into());
}

if let Some(capacity) = usize_from_env("TOKIO_CONSOLE_BUFFER_CAPACITY") {
self.event_buffer_capacity = capacity;
}

self
}

Expand Down Expand Up @@ -765,3 +769,14 @@ fn duration_from_env(var_name: &str) -> Option<Duration> {
),
}
}

fn usize_from_env(var_name: &str) -> Option<usize> {
let var = std::env::var(var_name).ok()?;
match var.parse::<usize>() {
Ok(num) => Some(num),
Err(e) => panic!(
"failed to parse a usize from `{}={:?}`: {}",
var_name, var, e
),
}
}
Loading