Skip to content

Commit

Permalink
Use default registry over creating new registry
Browse files Browse the repository at this point in the history
  • Loading branch information
njgheorghita committed Sep 29, 2023
1 parent 2d84c74 commit 46974cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion portalnet/src/metrics/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use prometheus_exporter::{
},
};

/// TODO COMMENTS ON SETUP
/// Contains metrics reporters for use in the overlay network
/// (eg. `portalnet/src/overlay.rs` & `portalnet/src/overlay_service.rs`).
/// Metric types reported here include protocol messages, utp transfers,
/// and content validation.
#[derive(Clone)]
pub struct OverlayMetrics {
pub message_count: IntCounterVec,
Expand Down
8 changes: 4 additions & 4 deletions portalnet/src/metrics/portalnet.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use crate::metrics::overlay::OverlayMetrics;
use crate::metrics::storage::StorageMetrics;
use lazy_static::lazy_static;
use prometheus_exporter::prometheus::Registry;
use prometheus_exporter::prometheus::{default_registry, Registry};

lazy_static! {
pub static ref PORTALNET_METRICS: PortalnetMetrics = initialize_metrics_registry();
}

fn initialize_metrics_registry() -> PortalnetMetrics {
let registry = Registry::new();
PortalnetMetrics::new(registry).expect("failed to initialize metrics")
PortalnetMetrics::new().expect("failed to initialize metrics")
}

pub struct PortalnetMetrics {
Expand All @@ -18,7 +17,8 @@ pub struct PortalnetMetrics {
}

impl PortalnetMetrics {
pub fn new(registry: Registry) -> anyhow::Result<Self> {
pub fn new() -> anyhow::Result<Self> {
let registry = default_registry();
let overlay = OverlayMetrics::new(&registry)?;
let storage = StorageMetrics::new(&registry)?;
Ok(Self { overlay, storage })
Expand Down
1 change: 1 addition & 0 deletions portalnet/src/metrics/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use prometheus_exporter::{
},
};

/// Contains metrics reporters for portalnet storage.
#[derive(Clone, Debug)]
pub struct StorageMetrics {
pub content_storage_usage_bytes: GaugeVec,
Expand Down

0 comments on commit 46974cc

Please sign in to comment.