tracing for user management

This commit is contained in:
Robin Appelman 2024-02-10 18:33:01 +01:00
commit a22f304ae2

View file

@ -7,6 +7,7 @@ use reqwest::get;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{query, query_as, Executor, Postgres}; use sqlx::{query, query_as, Executor, Postgres};
use std::fmt::{Debug, Formatter}; use std::fmt::{Debug, Formatter};
use tracing::instrument;
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct User { pub struct User {
@ -43,6 +44,7 @@ struct UserResult {
} }
impl User { impl User {
#[instrument(skip(connection))]
pub async fn get( pub async fn get(
connection: impl Executor<'_, Database = Postgres> + Copy, connection: impl Executor<'_, Database = Postgres> + Copy,
steam_id: SteamId, steam_id: SteamId,
@ -101,6 +103,7 @@ impl User {
} }
} }
#[instrument]
async fn fetch(steam_id: &SteamId) -> Result<Profile> { async fn fetch(steam_id: &SteamId) -> Result<Profile> {
let SteamId::Id(steam_id) = steam_id else { let SteamId::Id(steam_id) = steam_id else {
return Err(Error::NotFound); return Err(Error::NotFound);