Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network: convert metrics to use attribute macro #208

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 62 additions & 27 deletions src/samplers/network/stats.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,63 @@
use crate::common::HISTOGRAM_GROUPING_POWER;
use crate::*;
use metriken::metric;

counter_with_histogram!(
NETWORK_RX_BYTES,
NETWORK_RX_BYTES_HISTOGRAM,
"network/receive/bytes",
"number of bytes received"
);
counter_with_histogram!(
NETWORK_RX_PACKETS,
NETWORK_RX_PACKETS_HISTOGRAM,
"network/receive/frames",
"number of packets received"
);

counter_with_histogram!(
NETWORK_TX_BYTES,
NETWORK_TX_BYTES_HISTOGRAM,
"network/transmit/bytes",
"number of bytes transmitted"
);
counter_with_histogram!(
NETWORK_TX_PACKETS,
NETWORK_TX_PACKETS_HISTOGRAM,
"network/transmit/packets",
"number of packets transmitted"
);
use metriken::{metric, AtomicHistogram, Counter, Gauge, LazyCounter, LazyGauge};

#[metric(
name = "network/receive/bytes",
description = "The number of bytes received over the network",
metadata = { unit = "bytes" }
)]
pub static NETWORK_RX_BYTES: LazyCounter = LazyCounter::new(Counter::default);

#[metric(
name = "network/receive/bytes",
description = "Distribution of network receive throughput from sample to sample",
metadata = { unit = "bytes/second" }
)]
pub static NETWORK_RX_BYTES_HISTOGRAM: AtomicHistogram =
AtomicHistogram::new(HISTOGRAM_GROUPING_POWER, 64);

#[metric(
name = "network/receive/packets",
description = "The number of packets received over the network",
metadata = { unit = "packets" }
)]
pub static NETWORK_RX_PACKETS: LazyCounter = LazyCounter::new(Counter::default);

#[metric(
name = "network/receive/packets",
description = "Distribution of network receive packet rate from sample to sample",
metadata = { unit = "packets/second" }
)]
pub static NETWORK_RX_PACKETS_HISTOGRAM: AtomicHistogram =
AtomicHistogram::new(HISTOGRAM_GROUPING_POWER, 64);

#[metric(
name = "network/transmit/bytes",
description = "The number of bytes transmitted over the network",
metadata = { unit = "bytes" }
)]
pub static NETWORK_TX_BYTES: LazyCounter = LazyCounter::new(Counter::default);

#[metric(
name = "network/transmit/bytes",
description = "Distribution of network transmit throughput from sample to sample",
metadata = { unit = "bytes/second" }
)]
pub static NETWORK_TX_BYTES_HISTOGRAM: AtomicHistogram =
AtomicHistogram::new(HISTOGRAM_GROUPING_POWER, 64);

#[metric(
name = "network/transmit/packets",
description = "The number of packets transmitted over the network",
metadata = { unit = "packets" }
)]
pub static NETWORK_TX_PACKETS: LazyCounter = LazyCounter::new(Counter::default);

#[metric(
name = "network/transmit/packets",
description = "Distribution of network transmit packet rate from sample to sample",
metadata = { unit = "packets/second" }
)]
pub static NETWORK_TX_PACKETS_HISTOGRAM: AtomicHistogram =
AtomicHistogram::new(HISTOGRAM_GROUPING_POWER, 64);
Loading