Skip to content

Commit e237678

Browse files
refactor ⚙: Refactored small things on dashboards
1 parent ad66620 commit e237678

File tree

3 files changed

+317
-108
lines changed

3 files changed

+317
-108
lines changed

src/ic-websocket-gateway/src/client_session_handler.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ impl ClientSessionHandler {
193193
let client_key = self.get_client_key(&client_session);
194194

195195
// Clients connection metrics
196-
let clients_connected_count = self.gateway_state.get_clients_count(canister_id);
197-
debug!("Clients connected: {}", clients_connected_count.to_string());
198-
gauge!("clients_connected_count", "canister_id" => canister_id.to_string()).set(clients_connected_count as f64);
196+
let clients_connected = self.gateway_state.get_clients_count(canister_id);
197+
debug!("Clients connected: {}", clients_connected.to_string());
198+
gauge!("clients_connected", "canister_id" => canister_id.to_string()).set(clients_connected as f64);
199199

200200
// Calculate the time it took to open the connection and record it using the timer started in ws_listener.rs
201201
let delta = self.start_connection_time.elapsed();
@@ -218,9 +218,9 @@ impl ClientSessionHandler {
218218
debug!("Client removed from gateway state");
219219

220220
// Clients connection metrics
221-
let clients_connected_count = self.gateway_state.get_clients_count(canister_id);
222-
debug!("Clients connected: {}", clients_connected_count.to_string());
223-
gauge!("clients_connected_count", "canister_id" => canister_id.to_string()).set(clients_connected_count as f64);
221+
let clients_connected = self.gateway_state.get_clients_count(canister_id);
222+
debug!("Clients connected: {}", clients_connected.to_string());
223+
gauge!("clients_connected", "canister_id" => canister_id.to_string()).set(clients_connected as f64);
224224

225225
let delta = client_start_session_time.elapsed();
226226
histogram!("connection_duration", "client_key" => client_key.to_string()).record(delta);
@@ -257,9 +257,9 @@ impl ClientSessionHandler {
257257
debug!("Client removed from gateway state");
258258

259259
// Clients connection metrics
260-
let clients_connected_count = self.gateway_state.get_clients_count(canister_id);
261-
debug!("Clients connected: {}", clients_connected_count.to_string());
262-
gauge!("clients_connected_count", "canister_id" => canister_id.to_string()).set(clients_connected_count as f64);
260+
let clients_connected = self.gateway_state.get_clients_count(canister_id);
261+
debug!("Clients connected: {}", clients_connected.to_string());
262+
gauge!("clients_connected", "canister_id" => canister_id.to_string()).set(clients_connected as f64);
263263

264264
let delta = client_start_session_time.elapsed();
265265
histogram!("connection_duration", "client_key" => client_key.to_string()).record(delta);

src/ic-websocket-gateway/src/gateway_metrics.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,16 @@ pub fn init_metrics(port: Option<u16>) -> Result<(), Box<dyn Error>> {
99
let builder = PrometheusBuilder::new()
1010
.with_http_listener(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), port.unwrap_or(9000)));
1111

12-
// Set the idle timeout for counters and histograms to 10 seconds then the metrics are removed from the registry
12+
// Set the idle timeout for counters and histograms to 30 seconds then the metrics are removed from the registry
1313
builder
1414
.idle_timeout(
15-
MetricKindMask::COUNTER | MetricKindMask::HISTOGRAM,
16-
Some(Duration::from_secs(10)),
17-
)
18-
.idle_timeout(
19-
MetricKindMask::GAUGE,
15+
MetricKindMask::ALL,
2016
Some(Duration::from_secs(30)),
2117
)
2218
.install()
2319
.expect("failed to install Prometheus recorder");
2420

25-
describe_gauge!("clients_connected_count", "The number of clients currently connected");
21+
describe_gauge!("clients_connected", "The number of clients currently connected");
2622
describe_gauge!("active_pollers", "The number of pollers currently connected");
2723
describe_histogram!(
2824
"connection_duration",

0 commit comments

Comments
 (0)