Skip to content

Commit

Permalink
Optimize metrics collection: remove commented code, adjust usercount …
Browse files Browse the repository at this point in the history
…query interval to every 100 iterations
  • Loading branch information
nullchinchilla committed Oct 25, 2024
1 parent b54372f commit d3f4655
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/bindercore_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,21 @@ impl BinderCoreV2 {
.await
.unwrap();

// if ctr % 10 == 0 {
let (usercount,): (i64,) = sqlx::query_as("select count(distinct id) from auth_logs where last_login > NOW() - interval '1 day'")
.fetch_one(& postgres)
.await.unwrap();
let (subcount,): (i64,) = sqlx::query_as("select count(*) from subscriptions")
let (subcount,): (i64,) =
sqlx::query_as("select count(*) from subscriptions")
.fetch_one(&postgres)
.await
.unwrap();
statsd_client.gauge("usercount", usercount as f64);
statsd_client.gauge("subcount", subcount as f64);
// }

if ctr % 100 == 0 {
let (usercount,): (i64,) = sqlx::query_as("select count(distinct id) from auth_logs where last_login > NOW() - interval '1 day'")
.fetch_one(& postgres)
.await.unwrap();

statsd_client.gauge("usercount", usercount as f64);

}
}
})
};
Expand Down

0 comments on commit d3f4655

Please sign in to comment.