Reputation: 223
I can see in the HikariCP MicrometerMetricsTracker class that hikaricp.connections.timeout metrics are exposed as counter metrics.
this.connectionTimeoutCounter = Counter.builder(METRIC_NAME_TIMEOUT_RATE)
.description("Connection timeout total count")
.tags(METRIC_CATEGORY, poolName)
.register(meterRegistry);
This by default is exposing the metrics as count which is keep on incrementing. I need to use it as a gauge metric which can give dynamic/live values that should be measured directly and not the total incrementing count. Is there any way we can do it? I am trying something like this but here I don't have the information on connection timeout:
Gauge.builder("my.custom.metric.gauge", () -> "need info of timeout")
.register(meterRegistry);
Upvotes: 0
Views: 1221
Reputation: 6903
connectionTimeoutCounter
tells you how many times a timeout happened. This is by definition a Counter. Depending on you backend this can be a cumulative (since the star of the app) value or a delta value (since the previous publish). If you are using a backend (i.e.: Prometheus) that uses cumulative counters, they should also offer some sort of a rate
function which should tell you how many timeout did happen in the time window you choose.
Upvotes: 1