Skip to content

Commit

Permalink
Fixes #2277
Browse files Browse the repository at this point in the history
  • Loading branch information
solonovamax committed Nov 11, 2024
1 parent 3cb49c2 commit 2d0be01
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ object JettyMetrics {
.name("jetty_request_time_seconds_max")
.help("Maximum time spent handling requests")
.unit(MetricsUnit.SECONDS)
.callback { callback -> callback.call(statisticsHandler.requestTimeMax.milliseconds.toDouble(DurationUnit.SECONDS)) }
.callback { callback -> callback.call(statisticsHandler.requestTimeMax.toMillisFinite()) }
.register()

CounterWithCallback.builder()
.name("jetty_request_time_seconds_total")
.help("Total time spent in all request handling")
.unit(MetricsUnit.SECONDS)
.callback { callback -> callback.call(statisticsHandler.requestTimeTotal.milliseconds.toDouble(DurationUnit.SECONDS)) }
.callback { callback -> callback.call(statisticsHandler.requestTimeTotal.toMillisFinite()) }
.register()

GaugeWithCallback.builder()
.name("jetty_request_time_seconds_mean")
.help("Mean time spent in all request handling")
.unit(MetricsUnit.SECONDS)
.callback { callback -> callback.call(statisticsHandler.requestTimeMean.milliseconds.toDouble(DurationUnit.SECONDS)) }
.callback { callback -> callback.call(statisticsHandler.requestTimeMean.toMillisFinite()) }
.register()

GaugeWithCallback.builder()
.name("jetty_request_time_seconds_stddev")
.help("Standard deviation of time spent in all request handling")
.unit(MetricsUnit.SECONDS)
.callback { callback -> callback.call(statisticsHandler.requestTimeStdDev.milliseconds.toDouble(DurationUnit.SECONDS)) }
.callback { callback -> callback.call(statisticsHandler.requestTimeStdDev.toMillisFinite()) }
.register()

CounterWithCallback.builder()
Expand All @@ -100,28 +100,28 @@ object JettyMetrics {
.name("jetty_dispatched_time_seconds_max")
.help("Maximum time spent in dispatch handling")
.unit(MetricsUnit.SECONDS)
.callback { callback -> callback.call(statisticsHandler.dispatchedTimeMax.milliseconds.toDouble(DurationUnit.SECONDS)) }
.callback { callback -> callback.call(statisticsHandler.dispatchedTimeMax.toMillisFinite()) }
.register()

CounterWithCallback.builder()
.name("jetty_dispatched_time_seconds_total")
.help("Total time spent in dispatch handling")
.unit(MetricsUnit.SECONDS)
.callback { callback -> callback.call(statisticsHandler.dispatchedTimeTotal.milliseconds.toDouble(DurationUnit.SECONDS)) }
.callback { callback -> callback.call(statisticsHandler.dispatchedTimeTotal.toMillisFinite()) }
.register()

GaugeWithCallback.builder()
.name("jetty_dispatched_time_seconds_mean")
.help("Mean time spent in dispatch handling")
.unit(MetricsUnit.SECONDS)
.callback { callback -> callback.call(statisticsHandler.dispatchedTimeMean.milliseconds.toDouble(DurationUnit.SECONDS)) }
.callback { callback -> callback.call(statisticsHandler.dispatchedTimeMean.toMillisFinite()) }
.register()

GaugeWithCallback.builder()
.name("jetty_dispatched_time_seconds_stddev")
.help("Standard deviation of time spent in dispatch handling")
.unit(MetricsUnit.SECONDS)
.callback { callback -> callback.call(statisticsHandler.dispatchedTimeStdDev.milliseconds.toDouble(DurationUnit.SECONDS)) }
.callback { callback -> callback.call(statisticsHandler.dispatchedTimeStdDev.toMillisFinite()) }
.register()

CounterWithCallback.builder()
Expand Down Expand Up @@ -183,7 +183,7 @@ object JettyMetrics {
.name("jetty_stats_seconds")
.help("Time in seconds stats have been collected for")
.unit(MetricsUnit.SECONDS)
.callback { callback -> callback.call(statisticsHandler.statsOnMs.milliseconds.toDouble(DurationUnit.SECONDS)) }
.callback { callback -> callback.call(statisticsHandler.statsOnMs.toMillisFinite()) }
.register()

CounterWithCallback.builder()
Expand All @@ -192,4 +192,8 @@ object JettyMetrics {
.callback { callback -> callback.call(statisticsHandler.responsesBytesTotal.toDouble()) }
.register()
}

private fun Double.toMillisFinite() = if (this.isFinite()) this.milliseconds.toDouble(DurationUnit.SECONDS) else this

private fun Long.toMillisFinite() = this.milliseconds.toDouble(DurationUnit.SECONDS)
}

0 comments on commit 2d0be01

Please sign in to comment.