writeMetrics

fun writeMetrics(collectors: List<Collector>, withTimestamp: Boolean = false): String

Writes the metrics collected from the provided collectors into the Prometheus text exposition format.

This format is compatible with Prometheus' /metrics HTTP scraping interface.

Example output:

# TYPE http_requests_total counter
# HELP http_requests_total Total number of HTTP requests
http_requests_total{method="GET", status="200"} 1243

Return

A string in Prometheus-compatible text format.

Parameters

collectors

The list of Collector instances to serialize.

withTimestamp

If true, appends the collection timestamp to each sample line.