Skip to content

Commit

Permalink
fix: client registrations chart (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 authored May 17, 2024
1 parent 1c3a860 commit a74ad70
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 81 deletions.
3 changes: 0 additions & 3 deletions src/handlers/delete_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use {
crate::{
decrement_counter,
error::{Error::InvalidAuthentication, Result},
handlers::{authenticate_client, Response, DECENTRALIZED_IDENTIFIER_PREFIX},
log::prelude::*,
Expand Down Expand Up @@ -63,7 +62,5 @@ pub async fn handler(
"deleted client"
);

decrement_counter!(state.metrics, registered_clients);

Ok(Response::default())
}
7 changes: 1 addition & 6 deletions src/handlers/delete_tenant.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use {
crate::{
decrement_counter, error::Error, handlers::validate_tenant_request, log::prelude::*,
state::AppState,
},
crate::{error::Error, handlers::validate_tenant_request, log::prelude::*, state::AppState},
axum::{
extract::{Path, State},
http::HeaderMap,
Expand Down Expand Up @@ -42,8 +39,6 @@ pub async fn handler(

state.tenant_store.delete_tenant(&id).await?;

decrement_counter!(state.metrics, registered_tenants);

debug!(
tenant_id = %id,
"deleted tenant"
Expand Down
10 changes: 5 additions & 5 deletions src/metrics/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::error::{Error, Result},
opentelemetry::{
metrics::{Counter, UpDownCounter},
metrics::Counter,
sdk::{
self,
export::metrics::aggregation,
Expand All @@ -22,8 +22,8 @@ pub struct Metrics {
pub sent_fcm_v1_notifications: Counter<u64>,
pub sent_apns_notifications: Counter<u64>,

pub registered_clients: UpDownCounter<i64>,
pub registered_tenants: UpDownCounter<i64>,
pub registered_clients: Counter<u64>,
pub registered_tenants: Counter<u64>,

pub tenant_apns_updates: Counter<u64>,
pub tenant_fcm_updates: Counter<u64>,
Expand Down Expand Up @@ -54,12 +54,12 @@ impl Metrics {
let meter = opentelemetry::global::meter("echo-server");

let clients_counter = meter
.i64_up_down_counter("registered_clients")
.u64_counter("registered_clients")
.with_description("The number of currently registered clients")
.init();

let tenants_counter = meter
.i64_up_down_counter("registered_tenants")
.u64_counter("registered_tenants")
.with_description("The number of currently registered tenants")
.init();

Expand Down
69 changes: 2 additions & 67 deletions terraform/monitoring/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,71 +149,6 @@ resource "grafana_dashboard" "at_a_glance" {
"title" : "Notifications per Hour",
"type" : "stat"
},
{
"datasource" : {
"type" : "prometheus",
"uid" : grafana_data_source.prometheus.uid
},
"fieldConfig" : {
"defaults" : {
"color" : {
"mode" : "thresholds"
},
"mappings" : [],
"thresholds" : {
"mode" : "absolute",
"steps" : [
{
"color" : "green",
"value" : null
},
{
"color" : "red",
"value" : 80
}
]
}
},
"overrides" : []
},
"gridPos" : {
"h" : 8,
"w" : 10,
"x" : 11,
"y" : 0
},
"id" : 16,
"options" : {
"colorMode" : "value",
"graphMode" : "area",
"justifyMode" : "auto",
"orientation" : "auto",
"reduceOptions" : {
"calcs" : [
"lastNotNull"
],
"fields" : "",
"values" : false
},
"textMode" : "auto"
},
"pluginVersion" : "8.4.7",
"targets" : [
{
"datasource" : {
"type" : "prometheus",
"uid" : grafana_data_source.prometheus.uid
},
"exemplar" : true,
"expr" : "sum(rate(registered_clients{}[1h]))",
"interval" : "",
"legendFormat" : "",
"refId" : "A"
}
],
"title" : "Client Registrations per Hour",
"type" : "stat"
},
{
"gridPos" : {
"h" : 1,
Expand Down Expand Up @@ -417,13 +352,13 @@ resource "grafana_dashboard" "at_a_glance" {
"uid" : grafana_data_source.prometheus.uid
},
"exemplar" : true,
"expr" : "sum(increase(registered_clients{}[1h]))",
"expr" : "sum(rate(registered_clients{}[$__rate_interval]))",
"interval" : "",
"legendFormat" : "",
"refId" : "Clients"
}
],
"title" : "Registered Clients past 1h",
"title" : "Client registration rate",
"type" : "timeseries"
},
{
Expand Down

0 comments on commit a74ad70

Please sign in to comment.