Skip to content

Commit

Permalink
chore: rename prometheus registry and metrics for better consistency (#…
Browse files Browse the repository at this point in the history
…373)

* chore: all metrics under 'ceramic_one' prom registry

* chore: rename store metrics

was "ceramic_store_store_query_durations" and with the new c1 prefix "ceramic_one_ceramic_store_store_query_durations" and now "ceramic_one_store_query_durations"

* chore: rename http_api_http_api metric http_api_info
  • Loading branch information
dav1do authored Jun 18, 2024
1 parent a9f355d commit 5d40086
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion metrics/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) struct Core {

impl Default for Core {
fn default() -> Self {
let mut reg = Registry::default();
let mut reg = Registry::with_prefix("ceramic_one");
Core {
bitswap_metrics: bitswap::Metrics::new(&mut reg),
libp2p_metrics: libp2p::metrics::Metrics::new(&mut reg),
Expand Down
6 changes: 1 addition & 5 deletions one/src/http_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ impl Metrics {
api_version: ceramic_api_server::API_VERSION,
kubo_api_version: ceramic_kubo_rpc_server::API_VERSION,
});
sub_registry.register(
"http_api",
"Information about the Ceramic and Kubo APIs",
info,
);
sub_registry.register("info", "Information about the Ceramic and Kubo APIs", info);

Self {
requests,
Expand Down
10 changes: 5 additions & 5 deletions store/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ impl From<&StorageQuery> for QueryLabels {
pub struct Metrics {
key_value_insert_count: Counter,

store_query_durations: Family<QueryLabels, Histogram>,
query_durations: Family<QueryLabels, Histogram>,
}

impl Metrics {
/// Register and construct Metrics
pub fn register(registry: &mut Registry) -> Self {
let sub_registry = registry.sub_registry_with_prefix("ceramic_store");
let sub_registry = registry.sub_registry_with_prefix("store");

register!(
key_value_insert_count,
Expand All @@ -59,7 +59,7 @@ impl Metrics {
);

register!(
store_query_durations,
query_durations,
"Durations of store queries in seconds",
Family::<QueryLabels, Histogram>::new_with_constructor(|| {
Histogram::new(exponential_buckets(0.005, 2.0, 20))
Expand All @@ -69,7 +69,7 @@ impl Metrics {

Self {
key_value_insert_count,
store_query_durations,
query_durations,
}
}
}
Expand All @@ -83,7 +83,7 @@ impl Recorder<InsertEvent> for Metrics {
impl Recorder<StorageQuery> for Metrics {
fn record(&self, event: &StorageQuery) {
let labels: QueryLabels = event.into();
self.store_query_durations
self.query_durations
.get_or_create(&labels)
.observe(event.duration.as_secs_f64());
}
Expand Down

0 comments on commit 5d40086

Please sign in to comment.