From 3000253e4e7c22ad2e2effa5bf52bb4942bcc4af Mon Sep 17 00:00:00 2001 From: davidgomesdev <10091092+davidgomesdev@users.noreply.github.com> Date: Wed, 24 Jun 2026 19:31:53 +0100 Subject: [PATCH 1/2] feat: add vote metric --- src/main.rs | 28 +++++++++++++++++++++++----- src/metrics.rs | 14 ++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8d891a5..27d1f0c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,8 +9,8 @@ use alertaemcena::metrics::{ record_event_send_duration, record_event_sent, record_events_fetched, record_get_events_by_month_duration, record_pipeline_error, record_pipeline_run_duration, record_pipeline_run_duration_without_event_gather, record_reaction_processing_duration, - record_vote_backup_duration, record_vote_backup_records, set_threads_active, MetricResult, - PipelineErrorKind, PipelineStage, + record_vote, record_vote_backup_duration, record_vote_backup_records, set_threads_active, + MetricResult, PipelineErrorKind, PipelineStage, }; use alertaemcena::tracing::setup_tracing; use chrono::Utc; @@ -80,7 +80,7 @@ async fn main() { } }); - backup_votes(&discord, users_to_backup).await; + backup_votes(&discord, users_to_backup, &config.voting_emojis).await; info!("Starting app"); } .instrument(root_span) @@ -157,8 +157,8 @@ async fn run( users_with_reactions } -#[instrument(skip(discord))] -pub async fn backup_votes(discord: &DiscordAPI, vec: Vec) { +#[instrument(skip(discord, vote_emojis))] +pub async fn backup_votes(discord: &DiscordAPI, vec: Vec, vote_emojis: &[EmojiConfig; 5]) { let backup_started_at = Instant::now(); let vote_backups_folder = "vote_backups/"; let vote_backup_file_path = format!( @@ -205,6 +205,24 @@ pub async fn backup_votes(discord: &DiscordAPI, vec: Vec) { .into_iter() .flatten() .concat(); + + for vote_record in &user_votes { + match vote_emojis + .iter() + .position(|emoji| emoji.to_string() == vote_record.user_vote.vote) + { + Some(index) => record_vote( + index as u64 + 1, + &vote_record.user_id.to_string(), + &vote_record.url, + ), + None => warn!( + "Unrecognized vote emoji '{}' for user {}", + vote_record.user_vote.vote, vote_record.user_id + ), + } + } + record_vote_backup_records(user_votes.len() as u64); let backup_votes_file = File::create(&vote_backup_file_path).await; diff --git a/src/metrics.rs b/src/metrics.rs index 2d96d96..0332716 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -166,6 +166,10 @@ lazy_static! { .u64_gauge("aec_threads_active") .with_description("Current active thread count per category") .init(); + static ref VOTE: Gauge = METER + .u64_gauge("aec_vote") + .with_description("Vote number (1-5) cast by a voter") + .init(); } pub fn record_events_fetched(category: &Category, count: u64) { @@ -221,3 +225,13 @@ pub fn record_pipeline_error(stage: PipelineStage, error_kind: PipelineErrorKind pub fn set_threads_active(category: &Category, count: u64) { THREADS_ACTIVE.record(count, &[category.into()]); } + +pub fn record_vote(vote_number: u64, voter: &str, event_url: &str) { + VOTE.record( + vote_number, + &[ + KeyValue::new("voter", voter.to_string()), + KeyValue::new("event_url", event_url.to_string()), + ], + ); +} From e5a1dc3dcf463c61d4faccf383781df15383fed3 Mon Sep 17 00:00:00 2001 From: davidgomesdev <10091092+davidgomesdev@users.noreply.github.com> Date: Wed, 24 Jun 2026 19:32:07 +0100 Subject: [PATCH 2/2] ci: update ghas --- .github/workflows/build.yaml | 6 +++--- .github/workflows/release.yaml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 29ffda8..419924e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -12,9 +12,9 @@ jobs: code: ${{ steps.filter.outputs.code }} workflows: ${{ steps.filter.outputs.workflows }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v2 + - uses: dorny/paths-filter@v3 id: filter with: filters: | @@ -39,7 +39,7 @@ jobs: steps: - uses: rui314/setup-mold@v1 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1956f8f..17d207a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -38,7 +38,7 @@ jobs: working-directory: . steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 🦀 - Install Rust run: | @@ -71,7 +71,7 @@ jobs: if: github.ref_name == 'main' && github.event_name == 'push' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 📦 - Copy binary artifacts uses: actions/download-artifact@v4