Skip to content

Commit 0b764c1

Browse files
committed
Observe tokio runtime metrics
1 parent fe7359f commit 0b764c1

File tree

3 files changed

+455
-3
lines changed

3 files changed

+455
-3
lines changed

crates/cli/src/main.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,17 @@ impl sentry::TransportFactory for SentryTransportFactory {
5050
}
5151

5252
fn main() -> anyhow::Result<ExitCode> {
53-
let runtime = tokio::runtime::Builder::new_multi_thread()
54-
.enable_all()
55-
.build()?;
53+
let mut builder = tokio::runtime::Builder::new_multi_thread();
54+
builder.enable_all();
55+
56+
#[cfg(tokio_unstable)]
57+
builder
58+
.enable_metrics_poll_time_histogram()
59+
.metrics_poll_time_histogram_configuration(tokio::runtime::HistogramConfiguration::log(
60+
tokio::runtime::LogHistogram::default(),
61+
));
62+
63+
let runtime = builder.build()?;
5664

5765
runtime.block_on(async_main())
5866
}

crates/cli/src/telemetry.rs

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// SPDX-License-Identifier: AGPL-3.0-only
55
// Please see LICENSE in the repository root for full details.
66

7+
mod tokio;
8+
79
use std::sync::{LazyLock, OnceLock};
810

911
use anyhow::Context as _;
@@ -60,6 +62,9 @@ pub fn setup(config: &TelemetryConfig) -> anyhow::Result<()> {
6062
init_tracer(&config.tracing).context("Failed to configure traces exporter")?;
6163
init_meter(&config.metrics).context("Failed to configure metrics exporter")?;
6264

65+
let handle = ::tokio::runtime::Handle::current();
66+
self::tokio::observe(handle.metrics());
67+
6368
Ok(())
6469
}
6570

0 commit comments

Comments
 (0)