Skip to content

Commit

Permalink
memory: convert metrics to use attribute macro (#207)
Browse files Browse the repository at this point in the history
Converts all memory metrics to use the attribute macro
  • Loading branch information
brayniac authored Mar 27, 2024
1 parent 297d106 commit 6b4887b
Showing 1 changed file with 71 additions and 12 deletions.
83 changes: 71 additions & 12 deletions src/samplers/memory/stats.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,73 @@
use crate::*;
use metriken::{metric, Counter, Gauge, LazyCounter, LazyGauge};

gauge!(MEMORY_TOTAL, "memory/total");
gauge!(MEMORY_FREE, "memory/free");
gauge!(MEMORY_AVAILABLE, "memory/available");
gauge!(MEMORY_BUFFERS, "memory/buffers");
gauge!(MEMORY_CACHED, "memory/cached");

counter!(MEMORY_NUMA_HIT, "memory/numa/hit");
counter!(MEMORY_NUMA_MISS, "memory/numa/miss");
counter!(MEMORY_NUMA_FOREIGN, "memory/numa/foreign");
counter!(MEMORY_NUMA_INTERLEAVE, "memory/numa/interleave");
counter!(MEMORY_NUMA_LOCAL, "memory/numa/local");
counter!(MEMORY_NUMA_OTHER, "memory/numa/other");
#[metric(
name = "memory/total",
description = "The total amount of system memory",
metadata = { unit = "bytes" }
)]
pub static MEMORY_TOTAL: LazyGauge = LazyGauge::new(Gauge::default);

#[metric(
name = "memory/free",
description = "The amount of system memory that is currently free",
metadata = { unit = "bytes" }
)]
pub static MEMORY_FREE: LazyGauge = LazyGauge::new(Gauge::default);

#[metric(
name = "memory/available",
description = "The amount of system memory that is available for allocation",
metadata = { unit = "bytes" }
)]
pub static MEMORY_AVAILABLE: LazyGauge = LazyGauge::new(Gauge::default);

#[metric(
name = "memory/buffers",
description = "The amount of system memory used for buffers",
metadata = { unit = "bytes" }
)]
pub static MEMORY_BUFFERS: LazyGauge = LazyGauge::new(Gauge::default);

#[metric(
name = "memory/cached",
description = "The amount of system memory used by the page cache",
metadata = { unit = "bytes" }
)]
pub static MEMORY_CACHED: LazyGauge = LazyGauge::new(Gauge::default);

#[metric(
name = "memory/numa/hit",
description = "The number of allocations that succeeded on the intended node"
)]
pub static MEMORY_NUMA_HIT: LazyCounter = LazyCounter::new(Counter::default);

#[metric(
name = "memory/numa/miss",
description = "The number of allocations that did not succeed on the intended node"
)]
pub static MEMORY_NUMA_MISS: LazyCounter = LazyCounter::new(Counter::default);

#[metric(
name = "memory/numa/foreign",
description = "The number of allocations that were not intended for a node that were serviced by this node"
)]
pub static MEMORY_NUMA_FOREIGN: LazyCounter = LazyCounter::new(Counter::default);

#[metric(
name = "memory/numa/interleave",
description = "The number of interleave policy allocations that succeeded on the intended node"
)]
pub static MEMORY_NUMA_INTERLEAVE: LazyCounter = LazyCounter::new(Counter::default);

#[metric(
name = "memory/numa/local",
description = "The number of allocations that succeeded on the local node"
)]
pub static MEMORY_NUMA_LOCAL: LazyCounter = LazyCounter::new(Counter::default);

#[metric(
name = "memory/numa/other",
description = "The number of allocations that on this node that were allocated by a process on another node"
)]
pub static MEMORY_NUMA_OTHER: LazyCounter = LazyCounter::new(Counter::default);

0 comments on commit 6b4887b

Please sign in to comment.