tdm_server_rust/telemetry/
http_client.rs1use super::skywalking::{create_exit_span, inject_outbound};
4use reqwest::{Client, RequestBuilder, Response};
5use tracing::Instrument;
6
7pub async fn execute(client: &Client, builder: RequestBuilder) -> Result<Response, reqwest::Error> {
9 let mut req = builder.build()?;
10 let method = req.method().clone();
11 let url = req.url().to_string();
12 let operation = format!("{} {}", method, req.url().path());
13
14 let exit_guard = create_exit_span("http.client", &url);
15 if let Some((_, ref peer)) = exit_guard {
16 inject_outbound(req.headers_mut(), &operation, peer);
17 }
18
19 let span = tracing::info_span!(
20 "http.client",
21 http.method = %method,
22 url.full = %url,
23 );
24 async move { client.execute(req).await }
25 .instrument(span)
26 .await
27}