-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make prometheus configurable at compile time
- Loading branch information
1 parent
abbc176
commit c3d5bad
Showing
8 changed files
with
77 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::cell::Cell; | ||
|
||
#[cfg(feature = "prometheus")] | ||
mod prometheus; | ||
|
||
#[cfg(feature = "prometheus")] | ||
pub use prometheus::*; | ||
|
||
thread_local! { | ||
pub(crate) static IGNORED_BY_PACKET_FILTER_PKT: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static IGNORED_BY_PACKET_FILTER_BYTE: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static DROPPED_MIDDLE_OF_CONNECTION_TCP_PKT: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static DROPPED_MIDDLE_OF_CONNECTION_TCP_BYTE: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static TOTAL_PKT: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static TOTAL_BYTE: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static TCP_PKT: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static TCP_BYTE: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static UDP_PKT: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static UDP_BYTE: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static TCP_NEW_CONNECTIONS: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static UDP_NEW_CONNECTIONS: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static IDLE_CYCLES: Cell<u64> = const { Cell::new(0) }; | ||
pub(crate) static TOTAL_CYCLES: Cell<u64> = const { Cell::new(0) }; | ||
|
||
#[cfg(feature = "prometheus")] | ||
pub(crate) static PROMETHEUS: std::cell::OnceCell<prometheus::PerCorePrometheusStats> = const { std::cell::OnceCell::new() }; | ||
} | ||
|
||
pub(crate) trait StatExt: Sized { | ||
fn inc(&'static self) { | ||
self.inc_by(1); | ||
} | ||
fn inc_by(&'static self, val: u64); | ||
} | ||
|
||
impl StatExt for std::thread::LocalKey<Cell<u64>> { | ||
fn inc_by(&'static self, val: u64) { | ||
self.set(self.get() + val); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters