fn create_request_context()

in src/request.rs [285:317]


fn create_request_context(
    request_id: Option<i64>, header: Option<&str>, method: &str, url: &Url,
) -> crate::Result<()> {
    let propagation = header
        .map(decode_propagation)
        .transpose()
        .map_err(|e| anyhow!("decode propagation failed: {}", e))?;

    trace!("Propagation: {:?}", &propagation);

    let mut ctx = tracer::create_trace_context();

    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 span_object = span.span_object_mut();
    span_object.component_id = COMPONENT_PHP_ID;
    span_object.add_tag("url", url.to_string());
    span_object.add_tag("http.method", method);

    RequestContext::set_global(
        request_id,
        RequestContext {
            tracing_context: ctx,
            entry_span: span,
        },
    );

    Ok(())
}