-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(compute): Add some basic compute_ctl metrics
- Loading branch information
Showing
6 changed files
with
124 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use metrics::core::Collector; | ||
use metrics::proto::MetricFamily; | ||
use metrics::{register_int_counter_vec, register_uint_gauge_vec, IntCounterVec, UIntGaugeVec}; | ||
use once_cell::sync::Lazy; | ||
|
||
pub(crate) static INSTALLED_EXTENSIONS: Lazy<UIntGaugeVec> = Lazy::new(|| { | ||
register_uint_gauge_vec!( | ||
"compute_installed_extensions", | ||
"Number of databases where the version of extension is installed", | ||
&["extension_name", "version", "owned_by_superuser"] | ||
) | ||
.expect("failed to define a metric") | ||
}); | ||
|
||
pub enum CPlaneRequestMethod { | ||
GetSpec, | ||
} | ||
|
||
impl CPlaneRequestMethod { | ||
pub fn as_str(&self) -> &str { | ||
match self { | ||
CPlaneRequestMethod::GetSpec => "GetSpec", | ||
} | ||
} | ||
} | ||
|
||
pub(crate) static CPLANE_REQUESTS_TOTAL: Lazy<IntCounterVec> = Lazy::new(|| { | ||
register_int_counter_vec!( | ||
"compute_ctl_cplane_requests_total", | ||
"Total number of control plane requests made by the compute_ctl", | ||
&["method"] | ||
) | ||
.expect("failed to define a metric") | ||
}); | ||
|
||
pub(crate) static CPLANE_REQUESTS_FAILED: Lazy<IntCounterVec> = Lazy::new(|| { | ||
register_int_counter_vec!( | ||
"compute_ctl_cplane_requests_failed", | ||
"Total number of failed control plane requests made by the compute_ctl", | ||
&["method", "http_status"] | ||
) | ||
.expect("failed to define a metric") | ||
}); | ||
|
||
/// Total number of failed database migrations. Per-compute, this is actually a boolean metric, | ||
/// either empty or with a single value (1, migration_id) because we stop at the first failure. | ||
/// Yet, the sum over the fleet will provide the total number of failures. | ||
pub(crate) static DB_MIGRATION_FAILED: Lazy<IntCounterVec> = Lazy::new(|| { | ||
register_int_counter_vec!( | ||
"compute_ctl_db_migration_failed", | ||
"Total number of failed database migrations", | ||
&["migration_id"] | ||
) | ||
.expect("failed to define a metric") | ||
}); | ||
|
||
pub fn collect() -> Vec<MetricFamily> { | ||
let mut metrics = INSTALLED_EXTENSIONS.collect(); | ||
metrics.extend(CPLANE_REQUESTS_TOTAL.collect()); | ||
metrics.extend(CPLANE_REQUESTS_FAILED.collect()); | ||
metrics.extend(DB_MIGRATION_FAILED.collect()); | ||
metrics | ||
} |
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