-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update: fixed analytics #421
Changes from 3 commits
4a0de36
274b1df
3aa47e8
611de2f
3870695
f2f27d2
b0f6f62
019306e
aa6e5ed
ef5e630
922f0ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
use ::time::UtcOffset; | ||
use opentelemetry::metrics::{Counter, Gauge, Histogram, Meter}; | ||
use opentelemetry::metrics::{Counter, Gauge, Histogram, Meter, UpDownCounter}; | ||
use opentelemetry::trace::TracerProvider; | ||
use opentelemetry::{global, KeyValue}; | ||
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge; | ||
|
@@ -198,6 +198,24 @@ pub fn register_counter_metric_instrument<T: CounterType<T> + Display>( | |
T::register_counter(crate_meter, instrument_name, desc, unit) | ||
} | ||
|
||
pub trait UpDownCounterType<T> { | ||
fn register_counter(meter: &Meter, name: String, description: String, unit: String) -> UpDownCounter<T>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rename that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NA |
||
} | ||
|
||
impl UpDownCounterType<f64> for f64 { | ||
fn register_counter(meter: &Meter, name: String, description: String, unit: String) -> UpDownCounter<f64> { | ||
meter.f64_up_down_counter(name).with_description(description).with_unit(unit).init() | ||
} | ||
} | ||
pub fn register_up_down_counter_metric_instrument<T: UpDownCounterType<T> + Display>( | ||
crate_meter: &Meter, | ||
instrument_name: String, | ||
desc: String, | ||
unit: String, | ||
) -> UpDownCounter<T> { | ||
T::register_counter(crate_meter, instrument_name, desc, unit) | ||
} | ||
|
||
pub trait HistogramType<T> { | ||
fn register_histogram(meter: &Meter, name: String, description: String, unit: String) -> Histogram<T>; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,7 +185,7 @@ impl Mempool { | |
.expect("Poisoned lock") | ||
.insert_tx(MempoolTransaction { tx, arrived_at, converted_class }, force)?; | ||
|
||
self.metrics.accepted_transaction_counter.add(1, &[]); | ||
self.metrics.accepted_transaction_counter.add(1.0, &[]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need a decimal counter here? cant we stick with an integer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also why an upDownCounter if we never decrement? AM I missing something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, initially we were going store the flow of increase and decrease of transactions in the mempool, but now we deprecated that thought, removed the |
||
} | ||
|
||
Ok(()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,12 +91,12 @@ impl RpcMetrics { | |
} | ||
|
||
pub(crate) fn ws_disconnect(&self, now: Instant) { | ||
let micros = now.elapsed().as_secs(); | ||
let millis = now.elapsed().as_millis(); | ||
|
||
if let Some(counter) = self.ws_sessions_closed.as_ref() { | ||
counter.add(1, &[]); | ||
} | ||
self.ws_sessions_time.record(micros as f64, &[]); | ||
self.ws_sessions_time.record(millis as f64, &[]); | ||
} | ||
|
||
pub(crate) fn on_call(&self, req: &Request, transport_label: &'static str) { | ||
|
@@ -113,15 +113,15 @@ impl RpcMetrics { | |
tracing::trace!(target: "rpc_metrics", "[{transport_label}] on_response started_at={:?}", now); | ||
tracing::trace!(target: "rpc_metrics::extra", "[{transport_label}] result={}", rp.as_result()); | ||
|
||
let micros = now.elapsed().as_micros(); | ||
let millis = now.elapsed().as_millis(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my comment was about doing let time = now.elapsed();
tracing::debug!(
target: "rpc_metrics",
"[{transport_label}] {} call took {:?}",
req.method_name(),
time,
);
self.calls_time.record(time.to_millis() as f64, &[KeyValue::new("method", req.method_name().to_string())]); instead, using the Debug impl of Duration, not the Debug impl of u64 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, but don't you think this increases possibility of the two readings going out of sync, WDYT ? |
||
tracing::debug!( | ||
target: "rpc_metrics", | ||
"[{transport_label}] {} call took {} μs", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here you should remove μs seconds to mili There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. valid, done! |
||
req.method_name(), | ||
micros, | ||
millis, | ||
); | ||
|
||
self.calls_time.record(micros as f64, &[KeyValue::new("method", req.method_name().to_string())]); | ||
self.calls_time.record(millis as f64, &[KeyValue::new("method", req.method_name().to_string())]); | ||
|
||
self.calls_finished.add( | ||
1, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be great to document those functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NA