feat: organize tracing on query path (#3310)

* feat: organize tracing on query path

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* warp json conversion to TracingContext's methods

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* remove unnecessary .trace()

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* Update src/query/src/dist_plan/merge_scan.rs

Co-authored-by: Zhenchi <zhongzc_arch@outlook.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Zhenchi <zhongzc_arch@outlook.com>
This commit is contained in:
Ruihang Xia
2024-02-18 23:04:57 +08:00
committed by GitHub
parent df6260d525
commit 72cd443ba3
13 changed files with 52 additions and 18 deletions

View File

@@ -24,6 +24,7 @@ opentelemetry_sdk = { version = "0.21.0", features = ["rt-tokio"] }
parking_lot = { version = "0.12" }
prometheus.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio.workspace = true
tracing = "0.1"
tracing-appender = "0.2"

View File

@@ -89,4 +89,17 @@ impl TracingContext {
let context = Propagator::new().extract(fields);
Self(context)
}
/// Convert the tracing context to a JSON string in W3C trace context format.
pub fn to_json(&self) -> String {
serde_json::to_string(&self.to_w3c()).unwrap()
}
/// Create a new tracing context from a JSON string in W3C trace context format.
///
/// Illegal json string will produce an empty tracing context and no error will be reported.
pub fn from_json(json: &str) -> Self {
let fields: W3cTrace = serde_json::from_str(json).unwrap_or_default();
Self::from_w3c(&fields)
}
}