-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add metrics for prometheus * metrics: rename metrics * metrics: add lumen_queried_total
- Loading branch information
Showing
7 changed files
with
139 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,64 @@ | ||
use std::sync::atomic::AtomicI64; | ||
|
||
use prometheus_client::{registry::Registry, metrics::{gauge::Gauge, family::Family, counter::Counter}, encoding::EncodeLabelSet}; | ||
|
||
pub struct Metrics { | ||
pub registry: Registry, | ||
|
||
/// Count active lumina connections | ||
pub active_connections: Gauge<i64, AtomicI64>, | ||
|
||
/// Record connected client versions | ||
pub lumina_version: Family<LuminaVersion, Gauge>, | ||
|
||
/// Count new functions pushes | ||
pub new_funcs: Counter<u64>, | ||
|
||
/// Count pushed functions | ||
pub pushes: Counter<u64>, | ||
|
||
/// Count pulled functions (only found) | ||
pub pulls: Counter<u64>, | ||
|
||
/// Queried functions | ||
pub queried_funcs: Counter<u64>, | ||
} | ||
|
||
#[derive(EncodeLabelSet, Debug, Hash, Eq, PartialEq, Clone)] | ||
pub struct LuminaVersion { | ||
pub protocol_version: u32, | ||
} | ||
|
||
impl Default for Metrics { | ||
fn default() -> Self { | ||
let mut registry = Registry::default(); | ||
|
||
let active_connections = Gauge::default(); | ||
registry.register("lumen_active_connections", "Active Lumina connections", active_connections.clone()); | ||
|
||
let lumina_version = Family::<LuminaVersion, Gauge>::default(); | ||
registry.register("lumen_protocol_version", "Version of Lumina protocol being used", lumina_version.clone()); | ||
|
||
let new_funcs = Counter::default(); | ||
registry.register("lumen_new_funcs", "Pushes previously unknown functions", new_funcs.clone()); | ||
|
||
let pushes = Counter::default(); | ||
registry.register("lumen_pushes_total", "Total pushes functions", pushes.clone()); | ||
|
||
let pulls = Counter::default(); | ||
registry.register("lumen_pulls_total", "Total pulled functions", pulls.clone()); | ||
|
||
let queried_funcs = Counter::default(); | ||
registry.register("lumen_queried_total", "Total Queried functions", queried_funcs.clone()); | ||
|
||
Metrics { | ||
registry, | ||
active_connections, | ||
lumina_version, | ||
new_funcs, | ||
pushes, | ||
pulls, | ||
queried_funcs, | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -15,3 +15,4 @@ clap = "4.3" | |
tokio-native-tls = "0.3" | ||
native-tls = {version = "0.2"} | ||
warp = "0.3" | ||
prometheus-client = "0.21.2" |
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