Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[build]
rustflags = ["--cfg", "tokio_unstable"]

# On x86_64, we target the x86-64-v2 psABI, as it is a good compromise between
# modern CPU instructions and compatibility.
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "target-cpu=x86-64-v2"]
rustflags = ["--cfg", "tokio_unstable", "-C", "target-cpu=x86-64-v2"]
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
run: |
cargo test --no-fail-fast --workspace
env:
RUSTFLAGS: "-Cinstrument-coverage"
RUSTFLAGS: "-Cinstrument-coverage --cfg tokio_unstable"
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
DATABASE_URL: postgresql://postgres:postgres@localhost/postgres
SQLX_OFFLINE: "1"
Expand Down
3 changes: 3 additions & 0 deletions crates/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use vergen_gitcl::{Emitter, GitclBuilder, RustcBuilder};

fn main() -> anyhow::Result<()> {
// Instruct rustc that we'll be using #[cfg(tokio_unstable)]
println!("cargo::rustc-check-cfg=cfg(tokio_unstable)");

// At build time, we override the version through the environment variable
// VERGEN_GIT_DESCRIBE. In some contexts, it means this variable is set but
// empty, so we unset it here.
Expand Down
19 changes: 17 additions & 2 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,23 @@ impl sentry::TransportFactory for SentryTransportFactory {
}
}

#[tokio::main]
async fn main() -> anyhow::Result<ExitCode> {
fn main() -> anyhow::Result<ExitCode> {
let mut builder = tokio::runtime::Builder::new_multi_thread();
builder.enable_all();

#[cfg(tokio_unstable)]
builder
.enable_metrics_poll_time_histogram()
.metrics_poll_time_histogram_configuration(tokio::runtime::HistogramConfiguration::log(
tokio::runtime::LogHistogram::default(),
));

let runtime = builder.build()?;

runtime.block_on(async_main())
}

async fn async_main() -> anyhow::Result<ExitCode> {
// We're splitting the "fallible" part of main in another function to have a
// chance to shutdown the telemetry exporters regardless of if there was an
// error or not
Expand Down
5 changes: 5 additions & 0 deletions crates/cli/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.

mod tokio;

use std::sync::{LazyLock, OnceLock};

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

let handle = ::tokio::runtime::Handle::current();
self::tokio::observe(handle.metrics());

Ok(())
}

Expand Down
Loading
Loading