From b8aba9c15e853691b7599049d52804f3ec03e968 Mon Sep 17 00:00:00 2001 From: j1nxie Date: Sun, 17 Nov 2024 10:00:13 +0700 Subject: [PATCH] feat: tag `tracing::instrument` on everything --- src/chapter_tracker.rs | 1 + src/commands/fluff.rs | 1 + src/commands/help.rs | 1 + src/commands/manga.rs | 4 ++++ src/commands/role.rs | 3 +++ src/commands/status.rs | 1 + src/main.rs | 3 ++- 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/chapter_tracker.rs b/src/chapter_tracker.rs index df84333..1ba1310 100644 --- a/src/chapter_tracker.rs +++ b/src/chapter_tracker.rs @@ -4,6 +4,7 @@ use sea_orm::{ActiveModelTrait, EntityTrait, IntoActiveModel, Set}; use crate::{constants::MD_BLOCKED_LIST, models::manga, Data, Error}; +#[tracing::instrument(skip_all)] pub async fn chapter_tracker(http: &Http, webhook: &Webhook, data: &Data) -> Result<(), Error> { let manga_list = manga::Entity::find().all(&data.db).await?; diff --git a/src/commands/fluff.rs b/src/commands/fluff.rs index 5571cf5..647af27 100644 --- a/src/commands/fluff.rs +++ b/src/commands/fluff.rs @@ -6,6 +6,7 @@ use crate::{Context, Error}; /// /// you want to listen to squartatrice? here you go. #[poise::command(prefix_command, slash_command)] +#[tracing::instrument(skip_all)] pub async fn squartatrice(ctx: Context<'_>) -> Result<(), Error> { let random_number = rand::random::(); diff --git a/src/commands/help.rs b/src/commands/help.rs index f8c9450..44f2fee 100644 --- a/src/commands/help.rs +++ b/src/commands/help.rs @@ -2,6 +2,7 @@ use crate::{Context, Error}; /// print the list of commands and their usage #[poise::command(slash_command, prefix_command)] +#[tracing::instrument(skip_all)] pub async fn help( ctx: Context<'_>, #[description = "specific command to show help about"] command: Option, diff --git a/src/commands/manga.rs b/src/commands/manga.rs index f214faa..4700ce0 100644 --- a/src/commands/manga.rs +++ b/src/commands/manga.rs @@ -56,12 +56,14 @@ async fn check_md_client(ctx: Context<'_>) -> Result<(), Error> { guild_only, subcommands("add", "list", "sync") )] +#[tracing::instrument(skip_all)] pub async fn manga(_: Context<'_>) -> Result<(), Error> { Ok(()) } /// add a manga to the tracking list. #[poise::command(prefix_command, slash_command)] +#[tracing::instrument(skip_all, fields(input = %input))] pub async fn add( ctx: Context<'_>, #[description = "mangadex uuid or link of the manga you want to add."] input: String, @@ -292,6 +294,7 @@ pub async fn add( /// print the currently tracked list. #[poise::command(prefix_command, slash_command)] +#[tracing::instrument(skip_all)] pub async fn list(ctx: Context<'_>) -> Result<(), Error> { if check_md_client(ctx).await.is_err() { return Ok(()); @@ -544,6 +547,7 @@ pub async fn list(ctx: Context<'_>) -> Result<(), Error> { /// sync the local database to the mdlist. #[poise::command(prefix_command, slash_command)] +#[tracing::instrument(skip_all)] pub async fn sync(ctx: Context<'_>) -> Result<(), Error> { if check_md_client(ctx).await.is_err() { return Ok(()); diff --git a/src/commands/role.rs b/src/commands/role.rs index c78c114..6b30d46 100644 --- a/src/commands/role.rs +++ b/src/commands/role.rs @@ -17,12 +17,14 @@ use crate::{models::roles, Context, Error}; guild_only, subcommands("add", "remove") )] +#[tracing::instrument(skip_all)] pub async fn role(_: Context<'_>) -> Result<(), Error> { Ok(()) } /// add a self-assignable role from list. #[poise::command(slash_command, prefix_command)] +#[tracing::instrument(skip_all)] pub async fn add(ctx: Context<'_>) -> Result<(), Error> { let mut db_roles_find = roles::Entity::find().paginate(&ctx.data().db, 10); @@ -127,6 +129,7 @@ pub async fn add(ctx: Context<'_>) -> Result<(), Error> { /// remove a self-assignable role from your role list. #[poise::command(slash_command, prefix_command)] +#[tracing::instrument(skip_all, fields(input = %input))] pub async fn remove(ctx: Context<'_>) -> Result<(), Error> { let mut db_roles_find = roles::Entity::find().paginate(&ctx.data().db, 10); diff --git a/src/commands/status.rs b/src/commands/status.rs index d61d94a..a88ea19 100644 --- a/src/commands/status.rs +++ b/src/commands/status.rs @@ -9,6 +9,7 @@ use poise::serenity_prelude as serenity; /// get the bot's status. #[poise::command(prefix_command, slash_command)] +#[tracing::instrument(skip_all)] pub async fn status(ctx: Context<'_>) -> Result<(), Error> { ctx.send(poise::CreateReply::default().embed( serenity::CreateEmbed::new() diff --git a/src/main.rs b/src/main.rs index 04a1fc6..2333829 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ mod constants; mod migrator; mod models; +#[tracing::instrument(skip_all)] async fn event_handler( ctx: &serenity::Context, event: &serenity::FullEvent, @@ -325,7 +326,7 @@ async fn main() -> anyhow::Result<()> { .inspect_err(|e| tracing::error!(err = ?e, "an error occurred when registering commands"))?; Ok(data) - }) + }.in_current_span()) }) .build();