From c88bc77c5b3d476d832c3db83c0e097327474974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Tue, 29 Aug 2023 21:34:01 +0200 Subject: [PATCH] x --- rust/Cargo.lock | 16 ++-------------- rust/Cargo.toml | 4 ++-- rust/patch_issue_2599.patch | 19 +++++++++++++++++++ rust/src/routing/mod.rs | 6 +++--- rust/tracing | 1 + 5 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 rust/patch_issue_2599.patch create mode 160000 rust/tracing diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 7ca3cef..b9a78a9 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1321,7 +1321,7 @@ dependencies = [ "tower", "tower-http", "tracing", - "tracing-attributes 0.2.0", + "tracing-attributes", "tracing-log", "tracing-opentelemetry", "tracing-subscriber", @@ -2395,25 +2395,13 @@ dependencies = [ "cfg-if", "log", "pin-project-lite", - "tracing-attributes 0.1.26", + "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.29", -] - -[[package]] -name = "tracing-attributes" -version = "0.2.0" -source = "git+https://github.com/miwig/tracing?branch=master#29146260fb4615d271d2e899ad95a753bb42915e" dependencies = [ "proc-macro2", "quote", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index e1b9922..542213c 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -60,10 +60,10 @@ features = ["trace", "request-id"] version = "0.1" [dependencies.tracing-attributes] -version = "=0.2.0" +version = "0.1" [patch.crates-io] -tracing-attributes = { git = "https://github.com/miwig/tracing", branch = "master" } +tracing-attributes = { path = "./tracing/tracing-attributes" } [dependencies.tracing-subscriber] version = "0.3" diff --git a/rust/patch_issue_2599.patch b/rust/patch_issue_2599.patch new file mode 100644 index 0000000..49a40b2 --- /dev/null +++ b/rust/patch_issue_2599.patch @@ -0,0 +1,19 @@ +commit 08aa250dc73d6e36ebd7db9ebedb09ea36b377a0 +Author: Michael Wigard +Date: Wed May 24 13:10:31 2023 +0200 + + attributes: fix instrument with "log" feature + +diff --git a/tracing-attributes/src/expand.rs b/tracing-attributes/src/expand.rs +index d71366c6..59a2eed4 100644 +--- a/tracing-attributes/src/expand.rs ++++ b/tracing-attributes/src/expand.rs +@@ -340,7 +340,7 @@ fn gen_block( + // regression in case the level is enabled. + let __tracing_attr_span; + let __tracing_attr_guard; +- if tracing::level_enabled!(#level) { ++ if tracing::level_enabled!(#level) || tracing::if_log_enabled!(#level, {true} else {false}) { + __tracing_attr_span = #span; + #follows_from + __tracing_attr_guard = __tracing_attr_span.enter(); diff --git a/rust/src/routing/mod.rs b/rust/src/routing/mod.rs index c9386f4..83b094b 100644 --- a/rust/src/routing/mod.rs +++ b/rust/src/routing/mod.rs @@ -36,7 +36,7 @@ fn get_referer(headers: &HeaderMap) -> Result<&str, Error> { }) } -//#[tracing::instrument] +#[tracing::instrument] async fn simple_handler(State(state): State) -> &'static str { use tracing::Instrument; let pool = async { @@ -55,7 +55,7 @@ async fn simple_handler(State(state): State) -> &'static str { .await .unwrap() } - .instrument(tracing::warn_span!("init_pool")) + // .instrument(tracing::warn_span!("init_pool")) .await; tracing::warn!("test event"); @@ -66,7 +66,7 @@ async fn simple_handler(State(state): State) -> &'static str { .await .unwrap() } - .instrument(tracing::warn_span!("test_span")) + // .instrument(tracing::warn_span!("test_span")) .await; "ok" } diff --git a/rust/tracing b/rust/tracing new file mode 160000 index 0000000..4302064 --- /dev/null +++ b/rust/tracing @@ -0,0 +1 @@ +Subproject commit 430206459badca1f52963f3a6349784a5cea42aa