Skip to content

Commit 961a6f1

Browse files
authored
Rename metrics for stable and heap memory bytes (#2679)
* Rename metrics for stable and heap memory bytes * Revert changes in register * Revert changes showcase
1 parent a739488 commit 961a6f1

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

src/archive/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,9 @@ fn encode_metrics(w: &mut MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
634634
stable_size() as f64,
635635
"Number of stable memory pages used by this canister.",
636636
)?;
637+
// Don't use the prefix ii_archive so that it gets picked up by a default alarm.
637638
w.encode_gauge(
638-
"ii_archive_stable_memory_bytes",
639+
"stable_memory_bytes",
639640
(stable_size() * WASM_PAGE_SIZE_IN_BYTES) as f64,
640641
"Size of the stable memory allocated by this canister.",
641642
)?;
@@ -645,9 +646,10 @@ fn encode_metrics(w: &mut MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
645646
core::arch::wasm32::memory_size::<0>() as f64,
646647
"Number of heap memory pages used by this canister.",
647648
)?;
649+
// Don't use the prefix ii_archive so that it gets picked up by a default alarm.
648650
#[cfg(target_arch = "wasm32")]
649651
w.encode_gauge(
650-
"ii_archive_heap_memory_bytes",
652+
"heap_memory_bytes",
651653
(core::arch::wasm32::memory_size::<0>() as u64 * WASM_PAGE_SIZE_IN_BYTES) as f64,
652654
"Size of the heap memory allocated by this canister.",
653655
)?;

src/archive/tests/tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ mod metrics_tests {
521521
"ii_archive_virtual_memory_pages{kind=\"log_data\"}",
522522
"ii_archive_virtual_memory_pages{kind=\"anchor_index\"}",
523523
"ii_archive_stable_memory_pages",
524-
"ii_archive_stable_memory_bytes",
524+
"stable_memory_bytes",
525525
"ii_archive_heap_pages",
526-
"ii_archive_heap_memory_bytes",
526+
"heap_memory_bytes",
527527
// The metrics
528528
// * ii_archive_last_successful_fetch_timestamp_seconds
529529
// * ii_archive_last_successful_fetch_entries_count
@@ -674,7 +674,7 @@ mod metrics_tests {
674674
);
675675
assert_metric(
676676
&get_metrics(&env, canister_id),
677-
"ii_archive_stable_memory_bytes",
677+
"stable_memory_bytes",
678678
3074f64 * WASM_PAGE_SIZE as f64, // the memory_manager pre-allocates a lot of memory (1024 page buckets per virtual memory and some overhead)
679679
);
680680
assert_metric(
@@ -684,7 +684,7 @@ mod metrics_tests {
684684
);
685685
assert_metric(
686686
&get_metrics(&env, canister_id),
687-
"ii_archive_heap_memory_bytes",
687+
"heap_memory_bytes",
688688
49f64 * WASM_PAGE_SIZE as f64,
689689
);
690690

@@ -719,7 +719,7 @@ mod metrics_tests {
719719
);
720720
assert_metric(
721721
&get_metrics(&env, canister_id),
722-
"ii_archive_stable_memory_bytes",
722+
"stable_memory_bytes",
723723
3074f64 * WASM_PAGE_SIZE as f64, // does not change due to pre-allocation
724724
);
725725
assert_metric(
@@ -729,7 +729,7 @@ mod metrics_tests {
729729
);
730730
assert_metric(
731731
&get_metrics(&env, canister_id),
732-
"ii_archive_heap_memory_bytes", // does not change due to pre-allocation
732+
"heap_memory_bytes", // does not change due to pre-allocation
733733
51f64 * WASM_PAGE_SIZE as f64,
734734
);
735735

src/internet_identity/src/http/metrics.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ fn encode_metrics(w: &mut MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
8989
stable_size() as f64,
9090
"Number of stable memory pages used by this canister.",
9191
)?;
92+
// Don't use the prefix internet_identity so that it gets picked up by a default alarm.
9293
w.encode_gauge(
93-
"internet_identity_stable_memory_bytes",
94+
"stable_memory_bytes",
9495
(stable_size() * WASM_PAGE_SIZE_IN_BYTES) as f64,
9596
"Size of the stable memory allocated by this canister.",
9697
)?;
@@ -100,9 +101,10 @@ fn encode_metrics(w: &mut MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
100101
core::arch::wasm32::memory_size::<0>() as f64,
101102
"Number of heap memory pages used by this canister.",
102103
)?;
104+
// Don't use the prefix internet_identity so that it gets picked up by a default alarm.
103105
#[cfg(target_arch = "wasm32")]
104106
w.encode_gauge(
105-
"internet_identity_heap_memory_bytes",
107+
"heap_memory_bytes",
106108
(core::arch::wasm32::memory_size::<0>() as u64 * WASM_PAGE_SIZE_IN_BYTES) as f64,
107109
"Size of the heap memory allocated by this canister.",
108110
)?;

src/internet_identity/tests/integration/http.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ fn ii_canister_serves_http_metrics() -> Result<(), CallError> {
147147
"internet_identity_max_user_number",
148148
"internet_identity_signature_count",
149149
"internet_identity_stable_memory_pages",
150-
"internet_identity_stable_memory_bytes",
150+
"stable_memory_bytes",
151151
"internet_identity_heap_pages",
152-
"internet_identity_heap_memory_bytes",
152+
"heap_memory_bytes",
153153
"internet_identity_last_upgrade_timestamp",
154154
"internet_identity_inflight_challenges",
155155
"internet_identity_users_in_registration_mode",

0 commit comments

Comments
 (0)