Skip to content

Commit

Permalink
chore: making metrics name consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
geekbrother committed Nov 13, 2023
1 parent 9ccdb82 commit 5e96f88
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub struct Metrics {
pub processed_notifications: Counter<u64>,
pub dispatched_notifications: Counter<u64>,
pub notify_latency: Histogram<u64>,
pub spawned_publishing_workers: ObservableGauge<u64>,
pub publishing_worker_errors: Counter<u64>,
pub publishing_workers_count: ObservableGauge<u64>,
pub publishing_workers_errors: Counter<u64>,
}

impl Metrics {
Expand Down Expand Up @@ -115,13 +115,13 @@ impl Metrics {
.with_description("The amount of time it took to dispatch all notifications")
.init();

let spawned_publishing_workers = meter
.u64_observable_gauge("spawned_publishing_workers")
let publishing_workers_count = meter
.u64_observable_gauge("publishing_workers_count")
.with_description("The number of spawned publishing workers tasks")
.init();

let publishing_worker_errors = meter
.u64_counter("publishing_worker_errors")
let publishing_workers_errors = meter
.u64_counter("publishing_workers_errors")
.with_description("The number of publishing worker that ended with an error")
.init();

Expand All @@ -140,8 +140,8 @@ impl Metrics {
processed_notifications,
dispatched_notifications,
notify_latency,
spawned_publishing_workers,
publishing_worker_errors,
publishing_workers_count,
publishing_workers_errors,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/services/publisher_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async fn process_and_handle(

let ctx = Context::current();
if let Some(metrics) = metrics {
metrics.spawned_publishing_workers.observe(
metrics.publishing_workers_count.observe(
&ctx,
spawned_tasks_counter.load(Ordering::SeqCst) as u64,
&[],
Expand All @@ -129,15 +129,15 @@ async fn process_and_handle(

if let Err(e) = process_queued_messages(postgres, relay_http_client, metrics, analytics).await {
if let Some(metrics) = metrics {
metrics.publishing_worker_errors.add(&ctx, 1, &[]);
metrics.publishing_workers_errors.add(&ctx, 1, &[]);
}
warn!("Error on processing queued messages by the worker: {:?}", e);
}

spawned_tasks_counter.fetch_sub(1, Ordering::SeqCst);

if let Some(metrics) = metrics {
metrics.spawned_publishing_workers.observe(
metrics.publishing_workers_count.observe(
&ctx,
spawned_tasks_counter.load(Ordering::SeqCst) as u64,
&[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local targets = grafana.targets;
.configure(defaults.configuration.timeseries)
.addTarget(targets.prometheus(
datasource = ds.prometheus,
expr = 'sum(rate(spawned_publishing_workers_total{}[$__rate_interval]))',
expr = 'sum(rate(publishing_workers_count_total{}[$__rate_interval]))',
refId = "availability",
))
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local targets = grafana.targets;
.configure(defaults.configuration.timeseries)
.addTarget(targets.prometheus(
datasource = ds.prometheus,
expr = 'sum(rate(publishing_worker_errors_total{}[$__rate_interval]))',
expr = 'sum(rate(publishing_workers_errors_total{}[$__rate_interval]))',
refId = "availability",
))
}

0 comments on commit 5e96f88

Please sign in to comment.