【发布时间】:2021-08-29 10:58:58
【问题描述】:
我用 Rust 构建了一个微服务。我接收消息,根据消息请求文档,并使用结果调用 REST api。我使用 warp 构建了 REST api,并使用 reqwest 发送结果。我们使用 jaeger 进行跟踪和“b3”格式。我没有跟踪经验,并且是 Rust 初学者。
问题:我需要在下面添加 warp / reqwest 源以传播跟踪信息并添加我自己的跨度吗?
我的版本端点(为简单起见)如下所示:
pub async fn version() -> Result<impl warp::Reply, Infallible> {
Ok(warp::reply::with_status(VERSION, http::StatusCode::OK))
}
我假设我必须提取例如这里的traceid/trace信息。
我做的 reqwest 调用如下所示:
pub async fn get_document_content_as_text(
account_id: &str,
hash: &str,
) -> Result<String, Box<dyn std::error::Error>> {
let client = reqwest::Client::builder().build()?;
let res = client
.get(url)
.bearer_auth(TOKEN)
.send()
.await?;
if res.status().is_success() {}
let text = res.text().await?;
Ok(text)
}
我假设我必须在此处添加 traceid / 跟踪信息。
【问题讨论】:
标签: rust microservices jaeger distributed-tracing