Skip to content

Commit

Permalink
Expose memory usage in bytes (#6407)
Browse files Browse the repository at this point in the history
# Motivation

According to [this slack
thread](https://dfinity.slack.com/archives/CH4CADCJX/p1731504006265059),
by exposing heap and stable memory usage in bytes as metrics named
`heap_memory_bytes` and `stable_memory_bytes`, we automatically get some
alerts on high memory usage.

# Changes

1. Expose metrics.

# Tests

1. Manually at
https://qsgjb-riaaa-aaaaa-aaaga-cai.raw.dskloet-ingress.devenv.dfinity.network/metrics
2. Updated `e2e-test-metrics-present.keys`.

# Todos

- [ ] Add entry to changelog (if necessary).
not necessary
  • Loading branch information
dskloetd authored Feb 12, 2025
1 parent 45185a1 commit 532838a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rs/backend/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ pub fn encode_metrics(w: &mut MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
gibibytes(wasm_memory_size_bytes()),
"Amount of wasm memory used by this canister, in binary gigabytes",
)?;
w.encode_gauge(
"stable_memory_bytes",
stable_memory_size_bytes() as f64,
"Amount of stable memory used by this canister, in bytes",
)?;
w.encode_gauge(
"heap_memory_bytes",
wasm_memory_size_bytes() as f64,
"Amount of wasm memory used by this canister, in bytes",
)?;
w.encode_gauge(
"nns_dapp_migration_countdown",
f64::from(stats.migration_countdown.unwrap_or(0)),
Expand Down
2 changes: 2 additions & 0 deletions scripts/nns-dapp/e2e-test-metrics-present.keys
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
accounts_count
hardware_wallet_accounts_count
heap_memory_bytes
nns_dapp_migration_countdown
nns_dapp_stable_memory_size_gib
nns_dapp_wasm_memory_size_gib
stable_memory_bytes
sub_accounts_count

0 comments on commit 532838a

Please sign in to comment.