Skip to content

chore(metrics)!: align names with Prometheus base units#1740

Draft
rkuris wants to merge 3 commits intomainfrom
rkuris/standardize-metric-names
Draft

chore(metrics)!: align names with Prometheus base units#1740
rkuris wants to merge 3 commits intomainfrom
rkuris/standardize-metric-names

Conversation

@rkuris
Copy link
Member

@rkuris rkuris commented Mar 4, 2026

Why this should be merged

Firewood metrics should follow Prometheus naming best practices: https://prometheus.io/docs/practices/naming/

This includes changing everything to be in base units and adding appropriately named suffixes to variables.

How this works

Rename

Examples (old -> new):

  • proposals -> proposals_total
  • commit.latency_ms -> commit.latency_seconds_total
  • io.read_ms -> io.read_seconds_total
  • space.reused -> space.reused_bytes_total
  • commit_ms_bucket -> commit_duration_seconds

How this was tested

WIP

Breaking Changes

BREAKING CHANGE: all metric names changed; update dashboards, alerts, and external consumers.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Metrics Change Detection ⚠️

This PR contains changes related to metrics:

-    describe_counter!(COMMIT_MS, "Time spent committing via FFI (ms)");
-    describe_counter!(COMMIT_COUNT, "Count of commit operations via FFI");
+    describe_counter!(
+    describe_counter!(COMMIT_TOTAL, "Count of commit operations via FFI");
-    describe_counter!(PROPOSE_MS, "Time spent proposing via FFI (ms)");
-    describe_counter!(PROPOSE_COUNT, "Count of proposal operations via FFI");
+    describe_counter!(
+    describe_counter!(PROPOSE_TOTAL, "Count of proposal operations via FFI");
-    describe_counter!(BATCH_MS, "Time spent processing batches (ms)");
-    describe_counter!(BATCH_COUNT, "Count of batch operations completed");
+    describe_counter!(
+    describe_counter!(BATCH_TOTAL, "Count of batch operations completed");
-    describe_counter!(CACHED_VIEW_MISS, "Count of cached view misses");
-    describe_counter!(CACHED_VIEW_HIT, "Count of cached view hits");
-    describe_counter!(MERGE_COUNT, "Count of range proof merges via FFI");
+    describe_counter!(CACHED_VIEW_MISS_TOTAL, "Count of cached view misses");
+    describe_counter!(CACHED_VIEW_HIT_TOTAL, "Count of cached view hits");
+    describe_counter!(MERGE_TOTAL, "Count of range proof merges via FFI");
-metrics::counter!(concat!("my.metric", "_ms"), labels)
+metrics::counter!(concat!("my_metric", "_total"), labels)
+metrics::counter!(concat!("my_metric", "_seconds_total"), labels)
-        metrics::describe_counter!("my.operation", "Operation counter");
-        metrics::describe_counter!(concat!("my.operation", "_ms"), "Operation timing");
+        metrics::describe_counter!(concat!("my_operation", "_total"), "Operation counter");
+        metrics::describe_counter!(concat!("my_operation", "_seconds_total"), "Operation timing in seconds");
-    metrics::counter!("my.operation", __metrics_labels).increment(1);
-    metrics::counter!(concat!("my.operation", "_ms"), __metrics_labels)
+    metrics::counter!(concat!("my_operation", "_total"), __metrics_labels).increment(1);
+    metrics::counter!(concat!("my_operation", "_seconds_total"), __metrics_labels)
-                metrics::describe_counter!(concat!(#metric_prefix, "_ms"), #timing_desc);
+                metrics::describe_counter!(concat!(#metric_prefix, "_seconds"), #timing_desc);
-                metrics::describe_counter!(#metric_prefix, "Operation counter");
-                metrics::describe_counter!(concat!(#metric_prefix, "_ms"), "Operation timing in milliseconds");
+                metrics::describe_counter!(#metric_prefix, " Operation counter");
+                metrics::describe_counter!(concat!(#metric_prefix, "_seconds"), "Operation timing in seconds");
-            metrics::counter!(#metric_prefix, __metrics_labels).increment(1);
+            metrics::counter!(concat!(#metric_prefix, "_total"), __metrics_labels).increment(1);
-            metrics::counter!(concat!(#metric_prefix, "_ms"), __metrics_labels)
+            metrics::counter!(concat!(#metric_prefix, "_seconds_total"), __metrics_labels)
-            proposals: firewood_counter!(crate::registry::PROPOSALS),
+            proposals: firewood_counter!(crate::registry::PROPOSALS_TOTAL),
-    describe_counter!(PROPOSALS, "Number of proposals created");
+    describe_counter!(PROPOSALS_TOTAL, "Number of proposals created");
-    describe_counter!(INSERT, "Number of insert operations");
-    describe_counter!(REMOVE, "Number of remove operations");
+    describe_counter!(INSERT_TOTAL, "Number of insert operations");
+    describe_counter!(REMOVE_TOTAL, "Number of remove operations");
-    describe_counter!(COMMIT_LATENCY_MS, "Commit latency (ms)");
+    describe_counter!(COMMIT_LATENCY_SECONDS_TOTAL, "Commit latency (seconds)");
-/// let histogram = firewood_histogram!(registry::LATENCY_MS);
+/// let histogram = firewood_histogram!(registry::LATENCY_S);
-    describe_counter!(PROPOSE_NS, "Time spent in propose (ns)");
-    describe_counter!(PROPOSE_COUNT, "Number of propose calls");
-    describe_counter!(COMMIT_NS, "Time spent in commit (ns)");
-    describe_counter!(COMMIT_COUNT, "Number of commit calls");
+    describe_counter!(PROPOSE_SECONDS_TOTAL, "Time spent in propose (seconds)");
+    describe_counter!(PROPOSE_TOTAL, "Number of propose calls");
+    describe_counter!(COMMIT_SECONDS_TOTAL, "Time spent in commit (seconds)");
+    describe_counter!(COMMIT_TOTAL, "Number of commit calls");
-    describe_counter!(SPACE_FROM_END, "Amount of space allocated from end (bytes)");
-    describe_counter!(SPACE_FREED, "Amount of space freed (bytes)");
-    describe_counter!(DELETE_NODE, "Count of deleted nodes");
-    describe_counter!(FLUSH_NODES, "Time spent flushing nodes (ms)");
+    describe_counter!(
+    describe_counter!(SPACE_FREED_BYTES_TOTAL, "Amount of space freed (bytes)");
+    describe_counter!(DELETE_NODE_TOTAL, "Count of deleted nodes");
+    describe_counter!(
-    describe_counter!(READ_NODE, "Number of node reads");
-    describe_counter!(CACHE_NODE, "Number of node cache operations");
-    describe_counter!(CACHE_FREELIST, "Number of freelist cache operations");
+    describe_counter!(READ_NODE_TOTAL, "Number of node reads");
+    describe_counter!(CACHE_NODE_TOTAL, "Number of node cache operations");
+    describe_counter!(CACHE_FREELIST_TOTAL, "Number of freelist cache operations");
-    describe_counter!(IO_READ_MS, "IO read timing (ms)");
-    describe_counter!(IO_READ_COUNT, "Number of IO read operations");
+    describe_counter!(IO_READ_SECONDS_TOTAL, "IO read timing (seconds)");
+    describe_counter!(IO_READ_TOTAL, "Number of IO read operations");
-    describe_counter!(ring::EAGAIN_WRITE_RETRY, "Count of EAGAIN write retries");
-    describe_counter!(ring::FULL, "Count of ring buffer full events");
-    describe_counter!(ring::SQ_WAIT, "Count of submission queue waits");
-    describe_counter!(ring::PARTIAL_WRITE_RETRY, "Count of partial write retries");
+    describe_counter!(
+    describe_counter!(ring::FULL_TOTAL, "Count of ring buffer full events");
+    describe_counter!(ring::SQ_WAIT_TOTAL, "Count of submission queue waits");
+    describe_counter!(

However, the dashboard was not modified.

You may need to update benchmark/Grafana-dashboard.json accordingly.


This check is automated to help maintain the dashboard.

Rename Firewood metrics to follow Prometheus naming best practices: https://prometheus.io/docs/practices/naming/

Examples (old -> new):
- proposals -> proposals_total
- commit.latency_ms -> commit.latency_seconds_total
- io.read_ms -> io.read_seconds_total
- space.reused -> space.reused_bytes_total
- commit_ms_bucket -> commit_duration_seconds

BREAKING CHANGE: all metric names changed; update dashboards, alerts, and external consumers.
@rkuris rkuris force-pushed the rkuris/standardize-metric-names branch from 45ed052 to 749924e Compare March 4, 2026 21:47
@rkuris rkuris force-pushed the rkuris/standardize-metric-names branch from 749924e to 7890586 Compare March 4, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant