Skip to content
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

Merged
merged 11 commits into from
Dec 24, 2024
Merged

update: fixed analytics #421

merged 11 commits into from
Dec 24, 2024

Conversation

heemankv
Copy link
Contributor

@heemankv heemankv commented Dec 12, 2024

This PR introduces some fixes on the instrumentation code.

  • Registers response time in milliseconds instead of microseconds

@heemankv heemankv self-assigned this Dec 12, 2024
@Trantorian1 Trantorian1 added the bug Report an issue or unexpected behavior label Dec 13, 2024
Copy link
Collaborator

@Trantorian1 Trantorian1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add some clarifying information as to what this PR fixes? Also, I have had issues getting the Signoz dashboard running locally, is this pr related?

@heemankv
Copy link
Contributor Author

Could you please add some clarifying information as to what this PR fixes? Also, I have had issues getting the Signoz dashboard running locally, is this pr related?

This PR is not related to Signoz.

@heemankv heemankv requested a review from Trantorian1 December 17, 2024 07:04
@@ -196,6 +196,24 @@ pub fn register_counter_metric_instrument<T: CounterType<T> + Display>(
T::register_counter(crate_meter, instrument_name, desc, unit)
}

pub trait UpDownCounterType<T> {
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NA

@@ -196,6 +196,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>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename that register_up_down_counter to align with other declarations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NA

@@ -187,7 +187,7 @@ impl Mempool {
true,
)?;

self.metrics.accepted_transaction_counter.add(1, &[]);
self.metrics.accepted_transaction_counter.add(1.0, &[]);
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also why an upDownCounter if we never decrement? AM I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 up_down_counter logic completely

@@ -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();
tracing::debug!(
target: "rpc_metrics",
"[{transport_label}] {} call took {} μs",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you should remove μs seconds to mili

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid, done!

@heemankv heemankv requested a review from antiyro December 19, 2024 12:00
tracing::debug!(
target: "rpc_metrics",
"[{transport_label}] {} call took {} μs",
"[{transport_label}] {} call took {} ms",
Copy link
Member

@cchudant cchudant Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use Duration {:?} (Debug) impl instead? it'll add the s/ms/us suffix depending on the value - i think that's what we used to do before you switched the codebase to tracing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch !
Added

@heemankv heemankv requested a review from cchudant December 21, 2024 13:00
@@ -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();
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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,
let's say due to xyz reasons a RPC call took 1 sec, the tracing might record it as 1 sec but the calls_time metric will record it as 1000 milliseconds.
Whereas in the previous implementation both would have recorded 1000 milliseconds

WDYT ?

@heemankv heemankv requested a review from cchudant December 24, 2024 04:37
Copy link
Member

@cchudant cchudant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't mind merging this as is, i was nitpicking - in addition the time is already shown in a human format in an info-level log

@heemankv heemankv merged commit 22b039a into main Dec 24, 2024
10 checks passed
@heemankv heemankv deleted the fix/rework-analytics branch December 24, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report an issue or unexpected behavior
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants