Skip to content

Commit

Permalink
customizable max sample size option
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Dec 4, 2024
1 parent c1023b5 commit 29edd8e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions skystreamer-prometheus-exporter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,21 @@ async fn main() -> Result<()> {
.with_env_filter(env_filter)
.init();

let max_sample_size = std::env::var("MAX_SAMPLE_SIZE")
.unwrap_or_else(|_| "10000".to_string())
.parse::<usize>()?;

tracing::info!("Starting skystreamer-prometheus-exporter");
tracing::info!("MAX_SAMPLE_SIZE: {}", max_sample_size);

let binding = "0.0.0.0:9100".parse()?;
let _exporter = prometheus_exporter::start(binding)?;
let counter = register_counter!(
"skystreamer_bsky_posts",
"Number of posts from bsky.network"
)?;

const MAX_SAMPLE_SIZE: usize = 10000;
// const MAX_SAMPLE_SIZE: usize = 10000;

loop {
let subscription = RepoSubscription::new("bsky.network").await.unwrap();
Expand All @@ -51,7 +58,7 @@ async fn main() -> Result<()> {
// let mut last_tick = tokio::time::Instant::now();

while let Some(_post) = stream.next().await {
if counter.get() > MAX_SAMPLE_SIZE as f64 {
if counter.get() > max_sample_size as f64 {
counter.reset();
}

Expand Down

0 comments on commit 29edd8e

Please sign in to comment.