6 releases (3 breaking)
0.4.0 | Nov 30, 2024 |
---|---|
0.3.2 | Nov 21, 2023 |
0.2.0 | Aug 13, 2022 |
0.1.0 | Aug 9, 2022 |
#745 in Debugging
241 downloads per month
250KB
571 lines
rust-opentelemetry-auto-span
Usage
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
- function span (from
get_user
start to end) .await
ofsqlx::query*
span- also capture SQL string
- if error return (at
.await?
) and handle by?
, logging the error
See Examples.
Dependencies
~3–4.5MB
~84K SLoC