-
Notifications
You must be signed in to change notification settings - Fork 19
Precision truncation possibly not intended on timed with Seconds #152
Copy link
Copy link
Closed
Description
In the function timed more specifically timedSeconds we're currently doing integer division in the case of SECONDS and truncating valuable information that would be good for the metric.
For example if start and end were: 1000 ms in and 3300 ms past then we'd have a difference of 2.3 seconds but with the current implementation we would be 1s in and then 3s in which would be 2.0 in the end result as it is currently coded.
Something like the below would fix the truncation of data problem for the default sized buckets (seconds) at least.
def timedFixed[E, F[_]: Bracket[?[_], E]: Clock, A](h: Histogram[F], fa: F[A]): F[A] =
Bracket[F, E].bracket(Clock[F].monotonic(NANOSECONDS))
{_: Long => fa}
{start: Long => Clock[F].monotonic(NANOSECONDS).flatMap(now => h.observe(io.prometheus.client.SimpleTimer. elapsedSecondsFromNanos(start, now))}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels