Skip to content

Commit

Permalink
wip - metrics cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Sep 29, 2023
1 parent 99ef567 commit cdfc62f
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 291 deletions.
3 changes: 2 additions & 1 deletion cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::Error;
use crate::helpers::*;
use crate::imports::*;
pub use crate::metrics;
// pub use crate::metrics;
use crate::modules::miner::Miner;
use crate::modules::node::Node;
use crate::notifier::{Notification, Notifier};
Expand Down Expand Up @@ -192,6 +192,7 @@ impl KaspaCli {
}

pub fn register_metrics(self: &Arc<Self>) -> Result<()> {
use crate::modules::metrics;
register_handlers!(self, self.handlers(), [metrics]);
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub mod error;
mod helpers;
mod imports;
mod matchers;
pub mod metrics;
mod modules;
//pub mod metrics;
pub mod modules;
mod notifier;
pub mod result;
pub mod utils;
Expand Down
263 changes: 0 additions & 263 deletions cli/src/metrics/data.rs

This file was deleted.

1 change: 0 additions & 1 deletion cli/src/metrics/mod.rs → cli/src/metricsx/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//pub mod data;
#[allow(clippy::module_inception)]
pub mod metrics;

Expand Down
16 changes: 8 additions & 8 deletions cli/src/metrics/metrics.rs → cli/src/modules/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::imports::*;
use kaspa_metrics::{Metrics, MetricsSinkFn};
use kaspa_metrics::{Metrics as MetricsProcessor, MetricsSinkFn};
use workflow_core::runtime::is_nw;

#[derive(Describe, Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq, Ord, PartialOrd)]
Expand All @@ -16,24 +16,24 @@ impl DefaultSettings for MetricsSettings {
}
}

pub struct MetricsHandler {
pub struct Metrics {
settings: SettingsStore<MetricsSettings>,
mute: Arc<AtomicBool>,
metrics: Arc<Metrics>,
metrics: Arc<MetricsProcessor>,
}

impl Default for MetricsHandler {
impl Default for Metrics {
fn default() -> Self {
MetricsHandler {
Metrics {
settings: SettingsStore::try_new("metrics").expect("Failed to create miner settings store"),
mute: Arc::new(AtomicBool::new(true)),
metrics: Arc::new(Metrics::default()),
metrics: Arc::new(MetricsProcessor::default()),
}
}
}

#[async_trait]
impl Handler for MetricsHandler {
impl Handler for Metrics {
fn verb(&self, _ctx: &Arc<dyn Context>) -> Option<&'static str> {
Some("metrics")
}
Expand Down Expand Up @@ -66,7 +66,7 @@ impl Handler for MetricsHandler {
}
}

impl MetricsHandler {
impl Metrics {
pub fn register_sink(&self, target: MetricsSinkFn) {
self.metrics.register_sink(target);
}
Expand Down
1 change: 1 addition & 0 deletions cli/src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod help;
pub mod history;
pub mod import;
pub mod list;
pub mod metrics;
pub mod miner;
pub mod monitor;
pub mod mute;
Expand Down
2 changes: 1 addition & 1 deletion kos/src/metrics/ipc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::imports::*;
use kaspa_cli_lib::metrics::MetricsSnapshot;
use kaspa_metrics::MetricsSnapshot;

#[derive(Debug, Clone, PartialEq, Eq, Hash, BorshDeserialize, BorshSerialize, Serialize, Deserialize)]
pub enum MetricsOps {
Expand Down
6 changes: 3 additions & 3 deletions kos/src/metrics/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::toolbar::*;
use crate::imports::*;
use kaspa_cli_lib::metrics::{Metric, MetricsSnapshot};
use kaspa_metrics::{Metric, MetricsSnapshot};
use std::collections::HashMap;
use workflow_core::time::{HOURS, MINUTES};
use workflow_d3::container::*;
Expand All @@ -26,7 +26,7 @@ impl Metrics {
pub async fn try_new() -> Result<Arc<Self>> {
workflow_d3::load().await?;

let core_ipc_target = get_ipc_target(Modules::Core).await?.expect("Unable to aquire background window");
let core_ipc_target = get_ipc_target(Modules::Core).await?.expect("Unable to acquire background window");
let core = Arc::new(CoreIpc::new(core_ipc_target));

let settings = Arc::new(SettingsStore::<MetricsSettings>::try_new("metrics")?);
Expand Down Expand Up @@ -165,7 +165,7 @@ impl Metrics {
self.init_graphs().await?;

// this call reflects from core to terminal
// initiating metrica data relay
// initiating metrics data relay
self.core.metrics_ready().await?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion kos/src/metrics/toolbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::imports::*;
use crate::result::Result;
use std::{collections::HashMap, sync::MutexGuard};

use kaspa_cli_lib::metrics::Metric;
use kaspa_metrics::Metric;
use web_sys::{Document, Element, MouseEvent};
use workflow_d3::graph::GraphDuration;
#[allow(unused_imports)]
Expand Down
Loading

0 comments on commit cdfc62f

Please sign in to comment.