-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/1413-plain-text-component
- Loading branch information
Showing
8 changed files
with
93 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ mod cli; | |
mod db; | ||
mod jinja; | ||
mod logger; | ||
mod metrics; | ||
mod service; | ||
mod settings; | ||
mod utils; | ||
|
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 @@ | ||
//! Metrics related to Chain Follower analytics. |
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 @@ | ||
//! Metrics related to Chain Indexer analytics. |
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,60 @@ | ||
//! Metrics related to endpoint analytics. | ||
use std::sync::LazyLock; | ||
|
||
use prometheus::{register_histogram_vec, register_int_counter_vec, HistogramVec, IntCounterVec}; | ||
|
||
/// Labels for the metrics | ||
const METRIC_LABELS: [&str; 3] = ["endpoint", "method", "status_code"]; | ||
/// Labels for the client metrics | ||
const CLIENT_METRIC_LABELS: [&str; 2] = ["client", "status_code"]; | ||
|
||
// Prometheus Metrics maintained by the service | ||
|
||
/// HTTP Request duration histogram. | ||
pub(crate) static HTTP_REQ_DURATION_MS: LazyLock<HistogramVec> = LazyLock::new(|| { | ||
register_histogram_vec!( | ||
"http_request_duration_ms", | ||
"Duration of HTTP requests in milliseconds", | ||
&METRIC_LABELS | ||
) | ||
.unwrap() | ||
}); | ||
|
||
/// HTTP Request CPU Time histogram. | ||
pub(crate) static HTTP_REQ_CPU_TIME_MS: LazyLock<HistogramVec> = LazyLock::new(|| { | ||
register_histogram_vec!( | ||
"http_request_cpu_time_ms", | ||
"CPU Time of HTTP requests in milliseconds", | ||
&METRIC_LABELS | ||
) | ||
.unwrap() | ||
}); | ||
|
||
// No Tacho implemented to enable this. | ||
// static ref HTTP_REQUEST_RATE: GaugeVec = register_gauge_vec!( | ||
// "http_request_rate", | ||
// "Rate of HTTP requests per second", | ||
// &METRIC_LABELS | ||
// ) | ||
// .unwrap(); | ||
|
||
/// HTTP Request count histogram. | ||
pub(crate) static HTTP_REQUEST_COUNT: LazyLock<IntCounterVec> = LazyLock::new(|| { | ||
register_int_counter_vec!( | ||
"http_request_count", | ||
"Number of HTTP requests", | ||
&METRIC_LABELS | ||
) | ||
.unwrap() | ||
}); | ||
|
||
/// Client Request Count histogram. | ||
pub(crate) static CLIENT_REQUEST_COUNT: LazyLock<IntCounterVec> = LazyLock::new(|| { | ||
register_int_counter_vec!( | ||
"client_request_count", | ||
"Number of HTTP requests per client", | ||
&CLIENT_METRIC_LABELS | ||
) | ||
.unwrap() | ||
}); |
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 @@ | ||
//! Metrics related to memory analytics. |
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,18 @@ | ||
//! This module contains submodules related to metrics report and analytics. | ||
use prometheus::{default_registry, Registry}; | ||
|
||
pub(crate) mod chain_follower; | ||
pub(crate) mod chain_indexer; | ||
pub(crate) mod endpoint; | ||
pub(crate) mod memory; | ||
|
||
/// Initialize Prometheus metrics. | ||
/// | ||
/// ## Returns | ||
/// | ||
/// Returns the default prometheus registry. | ||
#[must_use] | ||
pub(crate) fn init_prometheus() -> Registry { | ||
default_registry().clone() | ||
} |
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