-
Notifications
You must be signed in to change notification settings - Fork 120
Parent span not set properly #120
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
In the OpenTelemetry Demo we have a Rust service using reqwest-middleware.
We have noticed that the Context Propagation is not working properly when using reqwest to call another service.
The issue is detailed in here: open-telemetry/opentelemetry-demo#1318
But to add a full context to this issue, here is where we are using it:
async fn request_quote(count: u32) -> Result<f64, Box<dyn std::error::Error>> {
// TODO: better testing here and default quote_service_addr
let quote_service_addr: String = format!(
"{}{}",
env::var("QUOTE_SERVICE_ADDR").expect("$QUOTE_SERVICE_ADDR is not set"),
"/getquote"
);
let mut reqbody = HashMap::new();
reqbody.insert("numberOfItems", count);
let client = ClientBuilder::new(reqwest::Client::new())
.with(TracingMiddleware::<SpanBackendWithUrl>::new())
.build();
let req = client.request(Method::POST, quote_service_addr);
let mut headers = HeaderMap::new();
let cx = Context::current();
global::get_text_map_propagator(|propagator| {
propagator.inject_context(&cx, &mut HeaderInjector(&mut headers))
});
let resp = req
.json(&reqbody)
.headers(headers)
.send()
.await?
.text_with_charset("utf-8")
.await?;
debug!("{:?}", resp);
match resp.parse::<f64>() {
Ok(f) => Ok(f),
Err(error) => Err(Box::new(error)),
}
}When shippingservice(Rust) calls quoteservice(PHP) the parent_id sent is not from the caller, but from the caller's parent.
The trace is currenly looking like this:
But it should be something like this:
checkoutservice oteldemo.ShippingService/GetQuote
|--> shippingservice oteldemo.ShippingService/GetQuote
|--> shippingservice POST
|--> quoteservice POST /getquote
|--> quoteservice {closure}
|--> quoteservice calculate-quote
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
