From 41dd742407e1a49e7163a21e7f6f4389422e5798 Mon Sep 17 00:00:00 2001 From: Daan Boerlage Date: Thu, 6 Apr 2023 17:15:28 +0200 Subject: [PATCH] Add trace endpoint for testing traces --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index cef7a21..f23d8a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,6 +37,10 @@ async fn stats(Path(rsn): Path) -> impl IntoResponse { (StatusCode::OK, convert_into_metrics(resp)) } +async fn get_trace() -> impl IntoResponse { + let trace_id = axum_tracing_opentelemetry::find_current_trace_id(); + axum::Json(serde_json::json!({ "my_trace_id": trace_id })) +} #[tokio::main] async fn main() -> Result<(), BoxError> { @@ -45,6 +49,7 @@ async fn main() -> Result<(), BoxError> { let app = Router::new() .route("/worlds", get(worlds)) .route("/stats/:rsn", get(stats)) + .route("/trace", get(get_trace)) .layer(response_with_trace_layer()) .layer(opentelemetry_tracing_layer());