Skip to content

Commit

Permalink
Polish "Tweak performance for Prometheus scraping endpoint"
Browse files Browse the repository at this point in the history
  • Loading branch information
mhalbritter committed Mar 9, 2022
1 parent fb3f3c5 commit d14980e
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -55,14 +55,14 @@ public PrometheusScrapeEndpoint(CollectorRegistry collectorRegistry) {
@ReadOperation(producesFrom = TextOutputFormat.class)
public WebEndpointResponse<String> scrape(TextOutputFormat format, @Nullable Set<String> includedNames) {
try {
Writer writer = new StringWriter(nextMetricsScrapeSize);
Writer writer = new StringWriter(this.nextMetricsScrapeSize);
Enumeration<MetricFamilySamples> samples = (includedNames != null)
? this.collectorRegistry.filteredMetricFamilySamples(includedNames)
: this.collectorRegistry.metricFamilySamples();
format.write(writer, samples);

String scrapePage = writer.toString();
nextMetricsScrapeSize = scrapePage.length() + METRICS_SCRAPE_CHARS_EXTRA;
this.nextMetricsScrapeSize = scrapePage.length() + METRICS_SCRAPE_CHARS_EXTRA;

return new WebEndpointResponse<>(scrapePage, format);
}
Expand Down

0 comments on commit d14980e

Please sign in to comment.