From 9085485a4f8a6be76d1ac8a8b7a7b65bdf83aa24 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Thu, 21 Apr 2022 18:07:33 +0100 Subject: tracing (#315) * enable tracing on server * fmt * instrument handlers --- atuin-server/src/handlers/history.rs | 5 +++++ atuin-server/src/handlers/user.rs | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'atuin-server/src/handlers') diff --git a/atuin-server/src/handlers/history.rs b/atuin-server/src/handlers/history.rs index 4fa2a962..b7112526 100644 --- a/atuin-server/src/handlers/history.rs +++ b/atuin-server/src/handlers/history.rs @@ -2,6 +2,7 @@ use axum::extract::Query; use axum::{extract::Path, Extension, Json}; use http::StatusCode; use std::collections::HashMap; +use tracing::{debug, error, instrument}; use crate::database::{Database, Postgres}; use crate::models::{NewHistory, User}; @@ -9,6 +10,7 @@ use atuin_common::api::*; use crate::calendar::{TimePeriod, TimePeriodInfo}; +#[instrument(skip_all, fields(user.id = user.id))] pub async fn count( user: User, db: Extension, @@ -27,6 +29,7 @@ pub async fn count( } } +#[instrument(skip_all, fields(user.id = user.id))] pub async fn list( req: Query, user: User, @@ -62,6 +65,7 @@ pub async fn list( Ok(Json(SyncHistoryResponse { history })) } +#[instrument(skip_all, fields(user.id = user.id))] pub async fn add( Json(req): Json>, user: User, @@ -90,6 +94,7 @@ pub async fn add( Ok(()) } +#[instrument(skip_all, fields(user.id = user.id))] pub async fn calendar( Path(focus): Path, Query(params): Query>, diff --git a/atuin-server/src/handlers/user.rs b/atuin-server/src/handlers/user.rs index 42e4aa33..a9a48fdc 100644 --- a/atuin-server/src/handlers/user.rs +++ b/atuin-server/src/handlers/user.rs @@ -6,6 +6,7 @@ use axum::extract::Path; use axum::{Extension, Json}; use http::StatusCode; use sodiumoxide::crypto::pwhash::argon2id13; +use tracing::{debug, error, instrument}; use uuid::Uuid; use crate::database::{Database, Postgres}; @@ -26,6 +27,7 @@ pub fn verify_str(secret: &str, verify: &str) -> bool { } } +#[instrument(skip_all, fields(user.username = username.as_str()))] pub async fn get( Path(username): Path, db: Extension, @@ -48,6 +50,7 @@ pub async fn get( })) } +#[instrument(skip_all)] pub async fn register( Json(register): Json, settings: Extension, @@ -95,6 +98,7 @@ pub async fn register( } } +#[instrument(skip_all, fields(user.username = login.username.as_str()))] pub async fn login( login: Json, db: Extension, -- cgit v1.3.1