Add more counters
This commit is contained in:
parent
605bc37db6
commit
48b50f783d
@ -1,6 +1,8 @@
|
|||||||
use poise::serenity_prelude::{Attachment, GuildId, RoleId};
|
use poise::serenity_prelude::{Attachment, GuildId, RoleId};
|
||||||
use tokio::fs::File;
|
use tokio::fs::File;
|
||||||
|
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
|
use crate::metrics::{DELETE_COUNTER, UPLOAD_COUNTER};
|
||||||
use crate::{
|
use crate::{
|
||||||
cmds::autocomplete_sound,
|
cmds::autocomplete_sound,
|
||||||
consts::{MAX_SOUNDS, PATREON_GUILD, PATREON_ROLE},
|
consts::{MAX_SOUNDS, PATREON_GUILD, PATREON_ROLE},
|
||||||
@ -21,6 +23,9 @@ pub async fn upload_new_sound(
|
|||||||
#[description = "Name to upload sound to"] name: String,
|
#[description = "Name to upload sound to"] name: String,
|
||||||
#[description = "Sound file (max. 2MB)"] file: Attachment,
|
#[description = "Sound file (max. 2MB)"] file: Attachment,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
|
UPLOAD_COUNTER.inc();
|
||||||
|
|
||||||
ctx.defer().await?;
|
ctx.defer().await?;
|
||||||
|
|
||||||
fn is_numeric(s: &String) -> bool {
|
fn is_numeric(s: &String) -> bool {
|
||||||
@ -110,6 +115,9 @@ pub async fn delete_sound(
|
|||||||
#[autocomplete = "autocomplete_sound"]
|
#[autocomplete = "autocomplete_sound"]
|
||||||
name: String,
|
name: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
|
DELETE_COUNTER.inc();
|
||||||
|
|
||||||
let pool = ctx.data().database.clone();
|
let pool = ctx.data().database.clone();
|
||||||
|
|
||||||
let uid = ctx.author().id.0;
|
let uid = ctx.author().id.0;
|
||||||
|
@ -25,13 +25,13 @@ pub async fn play(
|
|||||||
#[channel_types("Voice")]
|
#[channel_types("Voice")]
|
||||||
channel: Option<GuildChannel>,
|
channel: Option<GuildChannel>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
|
PLAY_COUNTER.inc();
|
||||||
|
|
||||||
ctx.defer().await?;
|
ctx.defer().await?;
|
||||||
|
|
||||||
let guild = ctx.guild().unwrap();
|
let guild = ctx.guild().unwrap();
|
||||||
|
|
||||||
#[cfg(feature = "metrics")]
|
|
||||||
PLAY_COUNTER.inc();
|
|
||||||
|
|
||||||
ctx.say(
|
ctx.say(
|
||||||
play_from_query(
|
play_from_query(
|
||||||
&ctx.serenity_context(),
|
&ctx.serenity_context(),
|
||||||
|
@ -8,7 +8,11 @@ use prometheus::{register_int_counter, IntCounter, Registry};
|
|||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref REGISTRY: Registry = Registry::new();
|
static ref REGISTRY: Registry = Registry::new();
|
||||||
pub static ref PLAY_COUNTER: IntCounter =
|
pub static ref PLAY_COUNTER: IntCounter =
|
||||||
register_int_counter!("play", "Number of calls to /play").unwrap();
|
register_int_counter!("play_cmd", "Number of calls to /play").unwrap();
|
||||||
|
pub static ref UPLOAD_COUNTER: IntCounter =
|
||||||
|
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 fn init_metrics() {
|
pub fn init_metrics() {
|
||||||
|
Loading…
Reference in New Issue
Block a user