-
Notifications
You must be signed in to change notification settings - Fork 161
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
feat: use millis in RPC metrics #4634
Conversation
That sounds great to me. |
@@ -44,7 +44,8 @@ where | |||
|
|||
metrics::RPC_METHOD_TIME | |||
.get_or_create(&method) | |||
.observe(start_time.elapsed().as_secs_f64()); | |||
// Observe the elapsed time in milliseconds | |||
.observe(start_time.elapsed().as_secs_f64() * 1000.0); |
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.
Too bad .as_millis_f64()
isn't stable.
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.
Yeah, that is disappointing.
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.
Could still use a millisecond
constant from Duration instead of the magic number.
.observe(start_time.elapsed().as_secs_f64() * 1000.0); | |
.observe(start_time.elapsed().as_secs_f64() * Duration::MILLISECOND as f64); |
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.
No, we couldn't. That constant is nightly-only. https://doc.rust-lang.org/std/time/struct.Duration.html#associatedconstant.MILLISECOND
Even if it wasn't nightly, the suggested code would still not work. Conceptually, you'd convert, e.g., 3s to 3ms.
We could introduce a named constant, but given it's used exclusively here and it's pretty trivial, combined with the comment above, I'm not convinced it'd bring any value.
Do you agree?
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.
Oops, yeah, this was a bit rushed. Not a blocker, however still not a fan of magic numbers. IMHO it's best to introduce a self-documenting constant than a comment, both are exactly one line of code.
Looks good to me, but would like to see the |
Summary of changes
Changes introduced in this pull request:
Based on the feedback from Glif:
Based on my subjective opinion (and so I'm open to reverting that):
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist