Skip to content

Commit

Permalink
Add individual language counter for bsky posts
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Dec 4, 2024
1 parent 8cb99d7 commit a62b6fb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion skystreamer-prometheus-exporter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ async fn main() -> Result<()> {
)?;

let language_counter = prometheus_exporter::prometheus::register_int_counter_vec!(
"skystreamer_bsky_posts_by_language",
"skystreamer_bsky_posts_by_language_grouped",
"Number of posts from bsky.network by language",
&["language"]
)?;

let language_counter_individual = prometheus_exporter::prometheus::register_int_counter_vec!(
"skystreamer_bsky_posts_by_language",
"Number of posts from bsky.network by language (individually)",
&["language"]
)?;

// const MAX_SAMPLE_SIZE: usize = 10000;

loop {
Expand All @@ -69,6 +75,10 @@ async fn main() -> Result<()> {
let langs = post.language.join(",");
language_counter.with_label_values(&[&langs]).inc();

post.language.iter().for_each(|lang| {
language_counter_individual.with_label_values(&[lang]).inc();
});

if let Some(max_size) = max_sample_size {
if counter.get() > max_size as u64 {
counter.reset();
Expand Down

0 comments on commit a62b6fb

Please sign in to comment.