Skip to content

Commit

Permalink
添加 const 暴露trace id
Browse files Browse the repository at this point in the history
  • Loading branch information
wentao committed Jun 7, 2023
1 parent 8342a2c commit ae344f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,17 @@ fn create_request_context(
trace!("Propagation: {:?}", &propagation);

let mut ctx = tracer::create_trace_context();
let c_ctx = ctx.trace_id();
// 定义一个PHP常量,常量值等于 skywalking 的 trace_id
call("define", [ZVal::from("SW_TRACE_ID"), ZVal::from(c_ctx)]).expect("define SW_TRACE_ID error");

let operation_name = format!("{}:{}", method, url.path());
let mut span = match propagation {
Some(propagation) => ctx.create_entry_span_with_propagation(&operation_name, &propagation),
None => ctx.create_entry_span(&operation_name),
};

let c_ctx = ctx.trace_id();
// 定义一个PHP常量,常量值等于 skywalking 的 trace_id
call("define", [ZVal::from("SW_TRACE_ID"), ZVal::from(c_ctx)]).expect("define SW_TRACE_ID error");

let mut span_object = span.span_object_mut();
span_object.component_id = COMPONENT_PHP_ID;
span_object.add_tag("url", url.to_string());
Expand Down

0 comments on commit ae344f5

Please sign in to comment.