Skip to content

Commit

Permalink
feat: tag tracing::instrument on everything
Browse files Browse the repository at this point in the history
  • Loading branch information
j1nxie committed Nov 17, 2024
1 parent 107d257 commit b8aba9c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/chapter_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand Down
1 change: 1 addition & 0 deletions src/commands/fluff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u8>();

Expand Down
1 change: 1 addition & 0 deletions src/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
Expand Down
4 changes: 4 additions & 0 deletions src/commands/manga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(());
Expand Down Expand Up @@ -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(());
Expand Down
3 changes: 3 additions & 0 deletions src/commands/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/commands/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mod constants;
mod migrator;
mod models;

#[tracing::instrument(skip_all)]
async fn event_handler(
ctx: &serenity::Context,
event: &serenity::FullEvent,
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit b8aba9c

Please sign in to comment.