This commit is contained in:
2023-08-29 21:34:01 +02:00
parent cad243123a
commit c88bc77c5b
5 changed files with 27 additions and 19 deletions

16
rust/Cargo.lock generated
View File

@@ -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",

View File

@@ -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"

View File

@@ -0,0 +1,19 @@
commit 08aa250dc73d6e36ebd7db9ebedb09ea36b377a0
Author: Michael Wigard <michael.wigard@uni-muenster.de>
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<B: ToTokens>(
// 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();

View File

@@ -36,7 +36,7 @@ fn get_referer(headers: &HeaderMap) -> Result<&str, Error> {
})
}
//#[tracing::instrument]
#[tracing::instrument]
async fn simple_handler(State(state): State<AppState>) -> &'static str {
use tracing::Instrument;
let pool = async {
@@ -55,7 +55,7 @@ async fn simple_handler(State(state): State<AppState>) -> &'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<AppState>) -> &'static str {
.await
.unwrap()
}
.instrument(tracing::warn_span!("test_span"))
// .instrument(tracing::warn_span!("test_span"))
.await;
"ok"
}

1
rust/tracing Submodule

Submodule rust/tracing added at 430206459b