open source / metrics4s / reading at scrape time
Reading at scrape time
Some values are cheaper to read when Prometheus asks for them. Each of these gives an Allocated[F, Unit], which the
runtime turns into its own resource (see Runtimes):
scala
Metrics[IO].observe(cacheSize)(_.report(cache.size.toDouble))
Metrics[IO].observeAll(scheduler.status())( // one read per scrape, several metrics
Observation(workers)((status, out) => out.report(status.workers.toDouble)),
Observation(load)((status, out) => out.report(status.load)),
)
Metrics[IO].observeAllF(queue.size, timeout = 1.second)( // a value only available in F
Observation(queueSize)((size, out) => out.report(size.toDouble))
)A callback that throws, or an F that runs past its timeout, does not break the scrape. Its metrics are left out of
that scrape, the F is cancelled, and metrics4s_callback_errors_total{metric="<first metric>"} counts it.
built from README.md at v0.2.0
edit this page on GitHub