From b56f60593e655e38f8610f6bc698be666189186a Mon Sep 17 00:00:00 2001 From: Frederik Rothenberger Date: Wed, 8 May 2024 16:06:38 +0200 Subject: [PATCH] Report heap size on /metrics (#2468) Currently, there is no reporting of the heap size and that metric has to be obtained from the respective replica dashboard. This PR makes the heap size more easily accessible so that we can put it onto the Grafana dashboard too. --- src/internet_identity/src/http/metrics.rs | 6 ++++++ src/internet_identity/tests/integration/http.rs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/internet_identity/src/http/metrics.rs b/src/internet_identity/src/http/metrics.rs index cdcfbe9240..ac80f5a25d 100644 --- a/src/internet_identity/src/http/metrics.rs +++ b/src/internet_identity/src/http/metrics.rs @@ -61,6 +61,12 @@ fn encode_metrics(w: &mut MetricsEncoder>) -> std::io::Result<()> { stable64_size() as f64, "Number of stable memory pages used by this canister.", )?; + #[cfg(target_arch = "wasm32")] + w.encode_gauge( + "internet_identity_heap_pages", + core::arch::wasm32::memory_size::<0>() as f64, + "Number of heap memory pages used by this canister.", + )?; w.encode_gauge( "internet_identity_temp_keys_count", state::with_temp_keys(|temp_keys| temp_keys.num_temp_keys()) as f64, diff --git a/src/internet_identity/tests/integration/http.rs b/src/internet_identity/tests/integration/http.rs index 986bc4d9ed..11e6d14853 100644 --- a/src/internet_identity/tests/integration/http.rs +++ b/src/internet_identity/tests/integration/http.rs @@ -145,6 +145,7 @@ fn ii_canister_serves_http_metrics() -> Result<(), CallError> { "internet_identity_max_user_number", "internet_identity_signature_count", "internet_identity_stable_memory_pages", + "internet_identity_heap_pages", "internet_identity_last_upgrade_timestamp", "internet_identity_inflight_challenges", "internet_identity_users_in_registration_mode",