Manually pass the current context around
This commit is contained in:
@@ -82,15 +82,16 @@ pub fn extract_context_from_request(req: &HttpRequest) -> Context {
|
||||
propagator.extract(&HeaderExtractor(req.headers()))
|
||||
}
|
||||
|
||||
pub fn trace_db_call<F, O>(query_type: &str, operation: &str, func: F) -> anyhow::Result<O>
|
||||
pub fn trace_db_call<F, O>(context: &Context, query_type: &str, operation: &str, func: F) -> anyhow::Result<O>
|
||||
where F: FnOnce() -> anyhow::Result<O> {
|
||||
|
||||
let tracer = global::tracer("db");
|
||||
let mut span = tracer
|
||||
.span_builder(format!("db.{}.{}", query_type, operation))
|
||||
.with_attributes(vec![
|
||||
KeyValue::new("db.query_type", query_type.to_string().clone()),
|
||||
KeyValue::new("db.operation", operation.to_string().clone()),
|
||||
]).start_with_context(&tracer, &Context::current());
|
||||
]).start_with_context(&tracer, context);
|
||||
|
||||
let result = func();
|
||||
match &result {
|
||||
|
||||
Reference in New Issue
Block a user