Skip to content

Commit d14980e

Browse files
committed
Polish "Tweak performance for Prometheus scraping endpoint"
See gh-30085
1 parent fb3f3c5 commit d14980e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusScrapeEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ public PrometheusScrapeEndpoint(CollectorRegistry collectorRegistry) {
5555
@ReadOperation(producesFrom = TextOutputFormat.class)
5656
public WebEndpointResponse<String> scrape(TextOutputFormat format, @Nullable Set<String> includedNames) {
5757
try {
58-
Writer writer = new StringWriter(nextMetricsScrapeSize);
58+
Writer writer = new StringWriter(this.nextMetricsScrapeSize);
5959
Enumeration<MetricFamilySamples> samples = (includedNames != null)
6060
? this.collectorRegistry.filteredMetricFamilySamples(includedNames)
6161
: this.collectorRegistry.metricFamilySamples();
6262
format.write(writer, samples);
6363

6464
String scrapePage = writer.toString();
65-
nextMetricsScrapeSize = scrapePage.length() + METRICS_SCRAPE_CHARS_EXTRA;
65+
this.nextMetricsScrapeSize = scrapePage.length() + METRICS_SCRAPE_CHARS_EXTRA;
6666

6767
return new WebEndpointResponse<>(scrapePage, format);
6868
}

0 commit comments

Comments
 (0)