use super::Stats;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Kind {
Gauge,
Counter,
}
#[derive(Clone, Copy, Debug)]
pub struct Metric {
pub name: &'static str,
pub help: &'static str,
pub kind: Kind,
pub read: fn(&Stats) -> u64,
}
pub const METRICS: [Metric; 13] = [
Metric {
name: "reserved_bytes",
help: "Bytes the allocator reserved from the operating system",
kind: Kind::Gauge,
read: |stats| stats.reserved_bytes,
},
Metric {
name: "pinned_bytes",
help: "Bytes of pinned reservations the allocator never purges",
kind: Kind::Gauge,
read: |stats| stats.pinned_bytes,
},
Metric {
name: "committed_bytes",
help: "Bytes the allocator currently has committed",
kind: Kind::Gauge,
read: |stats| stats.committed_bytes,
},
Metric {
name: "committed_peak_bytes",
help: "Peak bytes the allocator has had committed",
kind: Kind::Gauge,
read: |stats| stats.committed_peak_bytes,
},
Metric {
name: "allocated_bytes",
help: "Bytes handed out to callers, as of each thread's last statistics merge",
kind: Kind::Gauge,
read: |stats| stats.allocated_bytes,
},
Metric {
name: "pages",
help: "Allocator pages currently in use",
kind: Kind::Gauge,
read: |stats| stats.pages,
},
Metric {
name: "threads",
help: "Threads currently known to the allocator",
kind: Kind::Gauge,
read: |stats| stats.threads,
},
Metric {
name: "arenas",
help: "Arenas currently managed by the allocator",
kind: Kind::Gauge,
read: |stats| stats.arenas,
},
Metric {
name: "purged_bytes",
help: "Total bytes the allocator purged back to the operating system",
kind: Kind::Counter,
read: |stats| stats.purged_bytes,
},
Metric {
name: "purge_calls",
help: "Total purge operations performed by the allocator",
kind: Kind::Counter,
read: |stats| stats.purge_calls,
},
Metric {
name: "mmap_calls",
help: "Total memory mappings the allocator requested from the operating system",
kind: Kind::Counter,
read: |stats| stats.mmap_calls,
},
Metric {
name: "huge_allocations",
help: "Total allocations larger than the allocator's largest size class",
kind: Kind::Counter,
read: |stats| stats.huge_allocations,
},
Metric {
name: "huge_bytes",
help: "Total bytes of allocations larger than the allocator's largest size class",
kind: Kind::Counter,
read: |stats| stats.huge_bytes,
},
];