Skip to content

Commit

Permalink
Allow Prometheus formatting to arbitrary Writer
Browse files Browse the repository at this point in the history
  • Loading branch information
t-8ch authored and jkschneider committed Nov 29, 2018
1 parent 66cbbef commit 78e57b4
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,21 @@ private static List<String> tagValues(Meter.Id id) {
public String scrape() {
Writer writer = new StringWriter();
try {
TextFormat.write004(writer, registry.metricFamilySamples());
scrape(writer);
} catch (IOException e) {
// This actually never happens since StringWriter::write() doesn't throw any IOException
throw new RuntimeException(e);
}
return writer.toString();
}

/**
* @param writer Target that serves the content to be scraped by Prometheus.
*/
public void scrape(Writer writer) throws IOException {
TextFormat.write004(writer, registry.metricFamilySamples());
}

@Override
public Counter newCounter(Meter.Id id) {
MicrometerCollector collector = collectorByName(id);
Expand Down

0 comments on commit 78e57b4

Please sign in to comment.