org.http4s.metrics.prometheus

Members list

Type members

Classlikes

final case class MetricsCollection(responseDuration: Histogram, activeRequests: Gauge, requests: Counter, abnormalTerminations: Histogram)

Attributes

Source
Prometheus.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final class Prometheus[F[_]]

MetricsOps algebra capable of recording Prometheus metrics

MetricsOps algebra capable of recording Prometheus metrics

For example, the following code would wrap a org.http4s.HttpRoutes with a org.http4s.server.middleware.Metrics that records metrics to a given metric registry.

import cats.effect.{Resource, IO}
import org.http4s.server.middleware.Metrics
import org.http4s.metrics.Prometheus

val meteredRoutes: Resource[IO, HttpRoutes[IO]] =
 Prometheus.metricsOps[IO](registry, "server").map(ops => Metrics[IO](ops)(testRoutes))

Analogously, the following code would wrap a org.http4s.client.Client with a org.http4s.client.middleware.Metrics that records metrics to a given metric registry, classifying the metrics by HTTP method.

import cats.effect.{Resource, IO}
import org.http4s.client.middleware.Metrics
import org.http4s.metrics.Prometheus

val classifierFunc = (r: Request[IO]) => Some(r.method.toString.toLowerCase)
val meteredClient: Resource[IO, Client[IO]] =
 Prometheus.metricsOps[IO](registry, "client").map(ops => Metrics[IO](ops, classifierFunc)(client))

Registers the following metrics:

{prefix}_response_duration_seconds{labels=classifier,method,phase} - Histogram

{prefix}_active_request_count{labels=classifier} - Gauge

{prefix}_request_count{labels=classifier,method,status} - Counter

{prefix}_abnormal_terminations{labels=classifier,termination_type} - Histogram

Labels --

method: Enumeration values: get, put, post, head, move, options, trace, connect, delete, other

phase: Enumeration values: headers, body

code: Enumeration values: 1xx, 2xx, 3xx, 4xx, 5xx

termination_type: Enumeration values: abnormal, error, timeout

custom labels: custom labels, provided by customLabelsAndValues.map(_._1) values: custom label values, provided by customLabelsAndValues.map(_._2)

Attributes

Companion
object
Source
Prometheus.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object Prometheus

Attributes

Companion
class
Source
Prometheus.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Prometheus.type
final class PrometheusExportService[F[_]]

Attributes

Companion
object
Source
PrometheusExportService.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Source
PrometheusExportService.scala
Supertypes
class Object
trait Matchable
class Any
Self type