Crates.io | opentelemetry-auto-span |
lib.rs | opentelemetry-auto-span |
version | 0.4.0 |
source | src |
created_at | 2022-08-09 11:36:48.269078 |
updated_at | 2024-11-30 12:04:25.648855 |
description | A helper library for opentelemetry tracing |
homepage | |
repository | https://github.com/hinohi/rust-opentelemetry-auto-span |
max_upload_size | |
id | 641734 |
size | 298,535 |
add dependencies
[dependencies]
opentelemetry-auto-span = "0.4"
annotate function
use opentelemetry_auto_span::auto_span;
#[get("/user/{id}")]
#[auto_span]
async fn get_user(
id: web::Path<(i64,)>,
db: web::Data<sqlx::MySqlPool>,
) -> actix_web::Result<HttpResponse, Error> {
let user: User = sqlx::query_as("SELECT * FROM users WHERE id = ?")
.bind(id.into_inner().0)
.fetch_one(&**db)
.await?;
Ok(HttpResponse::Ok().json(&user))
}
then, capture bellow information
get_user
start to end).await
of sqlx::query*
span
.await?
) and handle by ?
, logging the errorSee Examples.