mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-29 19:30:37 +00:00
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:
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user