Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Mar 6, 2024
1 parent db8112d commit 9f13584
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
11 changes: 8 additions & 3 deletions bindings/client/src/app_agent_websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion framework/instruments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use parking_lot::RwLock;
use std::collections::HashMap;
use std::sync::Arc;

mod metrics;
mod report;

#[derive(Default)]
Expand Down
27 changes: 12 additions & 15 deletions framework/instruments/src/report/metrics_report.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit 9f13584

Please sign in to comment.