Add more counters

This commit is contained in:
jude 2023-10-22 12:40:17 +01:00
parent 4c17286614
commit cd5651c7f6
4 changed files with 12 additions and 2 deletions

2
Cargo.lock generated
View File

@ -2215,7 +2215,7 @@ dependencies = [
[[package]]
name = "soundfx-rs"
version = "1.5.13"
version = "1.5.15"
dependencies = [
"axum",
"dashmap",

View File

@ -2,7 +2,7 @@
name = "soundfx-rs"
description = "Discord bot for custom sound effects and soundboards"
license = "AGPL-3.0-only"
version = "1.5.14"
version = "1.5.15"
authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018"

View File

@ -6,6 +6,8 @@ use poise::serenity_prelude::{
ActionRowComponent, Activity, Context, CreateActionRow, CreateComponents,
};
#[cfg(feature = "metrics")]
use crate::metrics::GREET_COUNTER;
use crate::{
cmds::search::SoundPager,
models::{
@ -73,6 +75,9 @@ pub async fn listener(ctx: &Context, event: &poise::Event<'_>, data: &Data) -> R
let (handler, _) = join_channel(&ctx, guild, user_channel).await;
#[cfg(feature = "metrics")]
GREET_COUNTER.inc();
play_audio(
&mut sound,
volume,

View File

@ -13,10 +13,15 @@ lazy_static! {
register_int_counter!("upload_cmd", "Number of calls to /upload").unwrap();
pub static ref DELETE_COUNTER: IntCounter =
register_int_counter!("delete_cmd", "Number of calls to /delete").unwrap();
pub static ref GREET_COUNTER: IntCounter =
register_int_counter!("greet_invoke", "Number of greet sounds played").unwrap();
}
pub fn init_metrics() {
REGISTRY.register(Box::new(PLAY_COUNTER.clone())).unwrap();
REGISTRY.register(Box::new(UPLOAD_COUNTER.clone())).unwrap();
REGISTRY.register(Box::new(DELETE_COUNTER.clone())).unwrap();
REGISTRY.register(Box::new(GREET_COUNTER.clone())).unwrap();
}
pub async fn serve() {