Skip to content
Draft
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
22 changes: 17 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions examples/metrics-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ publish = false
[dependencies]
tokio = { version = "1.51.0", features = ["rt-multi-thread", "macros", "time", "sync", "process"] }
tokio-util = { version = "0.7", features = ["rt"] }
axum = "0.8"
axum-core = "0.5"
# TODO: update this once this is merged upstream
axum = { git = "https://github.com/yulnr/axum", branch = "feat/custom-serve-executor" }
axum-core = { git = "https://github.com/yulnr/axum", branch = "feat/custom-serve-executor" }
hyper = "1"
hyper-util = { version = "0.1", features = ["tokio", "server-auto"] }
tower = "0.5"
Expand Down
177 changes: 0 additions & 177 deletions examples/metrics-service/src/axum_traced.rs

This file was deleted.

23 changes: 18 additions & 5 deletions examples/metrics-service/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod axum_traced;
mod buffer;
mod ddb;
mod routes;
Expand All @@ -10,7 +9,7 @@ use aws_config::BehaviorVersion;
use clap::Parser;
#[cfg(target_os = "linux")]
use dial9_tokio_telemetry::telemetry::{CpuProfilingConfig, SchedEventConfig};
use dial9_tokio_telemetry::telemetry::{RotatingWriter, TracedRuntime};
use dial9_tokio_telemetry::telemetry::{RotatingWriter, TelemetryHandle, TracedRuntime};
use tokio::runtime::Builder;
use tokio_util::sync::CancellationToken;

Expand Down Expand Up @@ -253,10 +252,11 @@ fn main() -> std::io::Result<()> {
}
});

axum_traced::serve(listener, app.into_make_service(), handle.clone())
let executor = TelemetryExecutor(handle);
axum::serve(listener, app.into_make_service())
.with_executor(executor)
.with_graceful_shutdown(async move { shutdown.cancelled().await })
.await
Copy link
Copy Markdown
Collaborator Author

@yulnr yulnr Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this unwrap diff is unrelated, unwrap no longer needed due to API change upstream

.unwrap();
.await;
});

// Drop the runtime first so worker threads exit and flush their
Expand All @@ -267,3 +267,16 @@ fn main() -> std::io::Result<()> {

Ok(())
}

/// Adapter to allow `TelemetryHandle` to be used as an executor for axum's serve.
#[derive(Clone)]
struct TelemetryExecutor(TelemetryHandle);

impl axum::serve::Executor for TelemetryExecutor {
fn execute<Fut>(&self, fut: Fut)
where
Fut: std::future::Future<Output = ()> + Send + 'static,
{
self.0.spawn(fut);
}
}
Loading