Skip to content

Commit 9bb6dac

Browse files
Publish consistent Proxy metrics
Closes gh-92
1 parent ba4b022 commit 9bb6dac

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

proxy-server/src/main/java/io/micrometer/prometheus/rsocket/PrometheusController.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ public PrometheusController(PrometheusMeterRegistry meterRegistry, PrometheusCon
7878
.tag("exception", "none")
7979
.publishPercentileHistogram()
8080
.register(meterRegistry);
81-
82-
this.scrapeTimerClosed = meterRegistry.timer("prometheus.proxy.scrape", "outcome", "closed", "exception", "none");
81+
this.scrapeTimerClosed = Timer.builder("prometheus.proxy.scrape")
82+
.tag("outcome", "closed")
83+
.tag("exception", "none")
84+
.publishPercentileHistogram()
85+
.register(meterRegistry);
8386
this.scrapePayload = DistributionSummary.builder("prometheus.proxy.scrape.payload")
8487
.publishPercentileHistogram()
8588
.baseUnit("bytes")
@@ -173,9 +176,13 @@ public Mono<String> prometheus() {
173176
if (throwable instanceof ClosedChannelException) {
174177
sample.stop(scrapeTimerClosed);
175178
} else {
176-
sample.stop(meterRegistry.timer("prometheus.proxy.scrape",
177-
"outcome", "error",
178-
"exception", throwable.getMessage()));
179+
sample.stop(
180+
Timer.builder("prometheus.proxy.scrape")
181+
.tag("outcome", "error")
182+
.tag("exception", throwable.getMessage())
183+
.publishPercentileHistogram()
184+
.register(meterRegistry)
185+
);
179186
}
180187

181188
return connectionState.getDyingPush();

0 commit comments

Comments
 (0)