diff --git a/bindings/client/src/app_agent_websocket.rs b/bindings/client/src/app_agent_websocket.rs index 3b8ff286..c8459baa 100644 --- a/bindings/client/src/app_agent_websocket.rs +++ b/bindings/client/src/app_agent_websocket.rs @@ -71,10 +71,15 @@ impl AppAgentWebsocketInstrumented { } } -fn pre_call_zome(operation_record: &mut OperationRecord, _target: &ZomeCallTarget, zome_name: &ZomeName, fn_name: &FunctionName, _payload: &ExternIO) { - operation_record.add_attr("zome_name",zome_name.to_string()); +fn pre_call_zome( + operation_record: &mut OperationRecord, + _target: &ZomeCallTarget, + zome_name: &ZomeName, + fn_name: &FunctionName, + _payload: &ExternIO, +) { + operation_record.add_attr("zome_name", zome_name.to_string()); operation_record.add_attr("fn_name", fn_name.to_string()); - } impl Deref for AppAgentWebsocketInstrumented { diff --git a/framework/instruments/src/lib.rs b/framework/instruments/src/lib.rs index b66ff0fe..aa411f77 100644 --- a/framework/instruments/src/lib.rs +++ b/framework/instruments/src/lib.rs @@ -3,7 +3,6 @@ use parking_lot::RwLock; use std::collections::HashMap; use std::sync::Arc; -mod metrics; mod report; #[derive(Default)] diff --git a/framework/instruments/src/report/metrics_report.rs b/framework/instruments/src/report/metrics_report.rs index 3064a7a9..eac93f42 100644 --- a/framework/instruments/src/report/metrics_report.rs +++ b/framework/instruments/src/report/metrics_report.rs @@ -1,10 +1,9 @@ -use std::time::SystemTime; -use crate::metrics::{create_operation_duration_metric, OperationDurationMetric}; use crate::report::ReportCollector; use crate::OperationRecord; use anyhow::Context; use influxive_core::Metric; use influxive_writer::InfluxiveWriter; +use std::time::SystemTime; pub struct MetricsReportCollector { pub writer: InfluxiveWriter, @@ -25,27 +24,25 @@ impl MetricsReportCollector { )?, ); - Ok(Self { - writer, - }) + Ok(Self { writer }) } } impl ReportCollector for MetricsReportCollector { fn add_operation(&mut self, operation_record: &OperationRecord) { - let mut metric = Metric::new( - SystemTime::now(), - "operation_duration", - ) - .with_field("value", operation_record - .elapsed - .expect("OperationRecord must have an elapsed time") - .as_micros() as f64 - / 1000.0) + let mut metric = Metric::new(SystemTime::now(), "operation_duration") + .with_field( + "value", + operation_record + .elapsed + .expect("OperationRecord must have an elapsed time") + .as_micros() as f64 + / 1000.0, + ) .with_tag("operation_id", operation_record.operation_id.to_string()) .with_tag("is_error", operation_record.is_error.to_string()); for (k, v) in &operation_record.attr { - metric = metric.with_tag(k.to_string(), v.to_string()); + metric = metric.with_tag(k.to_string(), v.to_string()); } self.writer.write_metric(metric);