Skip to content

Commit

Permalink
kamon-prometheus: Add default buckets for Dimension.Percentage (#1266)
Browse files Browse the repository at this point in the history
* kamon-prometheus: Add default buckets for Dimension.Percentage

* fix compile error
  • Loading branch information
jatcwang committed Apr 4, 2023
1 parent f464db1 commit 4f18bba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions reporters/kamon-prometheus/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ kamon.prometheus {
1048576
]

percentage-buckets = [
20,
40,
60,
70,
80,
90,
95
]

# Per metric overrides are possible by specifying the metric name and the histogram buckets here
custom {
// example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ object PrometheusSettings {
defaultBuckets: Seq[java.lang.Double],
timeBuckets: Seq[java.lang.Double],
informationBuckets: Seq[java.lang.Double],
percentageBuckets: Seq[java.lang.Double],
customBuckets: Map[String, Seq[java.lang.Double]],
includeEnvironmentTags: Boolean,
summarySettings: SummarySettings,
Expand All @@ -47,6 +48,7 @@ object PrometheusSettings {
defaultBuckets = prometheusConfig.getDoubleList("buckets.default-buckets").asScala.toSeq,
timeBuckets = prometheusConfig.getDoubleList("buckets.time-buckets").asScala.toSeq,
informationBuckets = prometheusConfig.getDoubleList("buckets.information-buckets").asScala.toSeq,
percentageBuckets = prometheusConfig.getDoubleList("buckets.percentage-buckets").asScala.toSeq,
customBuckets = readCustomBuckets(prometheusConfig.getConfig("buckets.custom")),
includeEnvironmentTags = prometheusConfig.getBoolean("include-environment-tags"),
summarySettings = SummarySettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class ScrapeDataBuilder(prometheusConfig: PrometheusSettings.Generic, environmen
unit.dimension match {
case Time => prometheusConfig.timeBuckets
case Information => prometheusConfig.informationBuckets
case Percentage => prometheusConfig.percentageBuckets
case _ => prometheusConfig.defaultBuckets
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ class ScrapeDataBuilderSpec extends AnyWordSpec with Matchers {
buckets,
buckets,
buckets,
buckets,
customBuckets,
false,
SummarySettings(Seq(0.5, 0.75, 0.95, 0.99), withSummary.map(Glob)),
Expand Down

0 comments on commit 4f18bba

Please sign in to comment.