Adding metric support
This commit is contained in:
@@ -5,6 +5,8 @@ use poise::serenity_prelude::{
|
||||
ReactionType,
|
||||
};
|
||||
|
||||
#[cfg(feature = "prometheus")]
|
||||
use crate::metrics::PLAY_COUNTER;
|
||||
use crate::{
|
||||
cmds::autocomplete_sound,
|
||||
models::{guild_data::CtxGuildData, sound::SoundCtx},
|
||||
@@ -27,6 +29,9 @@ pub async fn play(
|
||||
|
||||
let guild = ctx.guild().unwrap();
|
||||
|
||||
#[cfg(feature = "prometheus")]
|
||||
PLAY_COUNTER.inc();
|
||||
|
||||
ctx.say(
|
||||
play_from_query(
|
||||
&ctx.serenity_context(),
|
||||
|
||||
@@ -105,10 +105,9 @@ pub async fn listener(ctx: &Context, event: &poise::Event<'_>, data: &Data) -> R
|
||||
let mut sound = sqlx::query_as_unchecked!(
|
||||
Sound,
|
||||
"
|
||||
SELECT name, id, public, server_id, uploader_id
|
||||
FROM sounds
|
||||
WHERE id = ?
|
||||
",
|
||||
SELECT name, id, public, server_id, uploader_id
|
||||
FROM sounds
|
||||
WHERE id = ?",
|
||||
join_id
|
||||
)
|
||||
.fetch_one(&data.database)
|
||||
|
||||
@@ -5,6 +5,8 @@ mod cmds;
|
||||
mod consts;
|
||||
mod error;
|
||||
mod event_handlers;
|
||||
#[cfg(feature = "prometheus")]
|
||||
mod metrics;
|
||||
mod models;
|
||||
mod utils;
|
||||
|
||||
|
||||
7
src/metrics.rs
Normal file
7
src/metrics.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use lazy_static;
|
||||
use prometheus::{register_int_counter, IntCounter};
|
||||
|
||||
lazy_static! {
|
||||
pub static ref PLAY_COUNTER: IntCounter =
|
||||
register_int_counter!("play", "Number of calls to /play").unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user