open source / metrics4s / the prometheus backend
The Prometheus backend
scala
given Metrics[IO] = PrometheusMetrics[IO](registry) // or PrometheusMetrics[IO](registry, MetricsConfig.default.withPreCreateLimit(1024))
PrometheusMetrics.jvm[IO](registry) // the client's own JVM metrics: jvm_memory_used_bytes, process_cpu_seconds_total, ...
PrometheusExporter.allocated[IO](9090, registry).toResource // HTTPServer; port 0 picks a free one, exporter.port says which
PrometheusScrape.text(registry) // the exposition, for a /metrics route of your ownThe registry is passed, never assumed. PrometheusRegistry.defaultRegistry is the one other Java libraries register
on, so services often want it. When they do, they write it out.
When the exporter cannot listen on its port, allocated fails with an ExporterException: its message and its port
name the port, and the bind failure is its cause.
built from README.md at v0.2.0
edit this page on GitHub