Skip to content

Commit

Permalink
return the same percentile rank that was requested on Distribution.pe…
Browse files Browse the repository at this point in the history
…rcentile(...), fixes #772
  • Loading branch information
ivantopo committed Jun 3, 2020
1 parent 1cbdc61 commit 103f5c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ class HistogramSpec extends WordSpec with Matchers with InstrumentInspection.Syn
)
}

"return the same percentile value that was request on a resulting distribution" in {
val histogram = Kamon.histogram("returned-percentile").withoutTags()
(1L to 10L).foreach(histogram.record)

val distribution = histogram.distribution()
distribution.percentile(99).rank shouldBe(99)
distribution.percentile(99.9).rank shouldBe(99.9)
distribution.percentile(99.99).rank shouldBe(99.99D)
}

"[private api] record values and optionally keep the internal state when a snapshot is taken" in {
val histogram = Kamon.histogram("test", unit = time.nanoseconds).withoutTags()
histogram.record(100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ object Distribution {
currentPercentile = percentiles.next()
}

currentPercentile
immutable.Percentile(p, currentPercentile.value, currentPercentile.countAtRank)

} else immutable.Percentile(p, 0, 0)
}
Expand Down

0 comments on commit 103f5c7

Please sign in to comment.