Packages

final class Prometheus[F[_]] extends AnyRef

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)

Self Type
Prometheus[F]
Source
Prometheus.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Prometheus
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def build: Resource[F, MetricsOps[F]]

    Build a MetricsOps that supports Prometheus metrics

  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  17. def toString(): String
    Definition Classes
    AnyRef → Any
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  19. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  20. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  21. def withCustomLabelsAndValues(customLabelsAndValues: List[(String, String)]): Prometheus[F]
  22. def withPrefix(prefix: String): Prometheus[F]
  23. def withRegister(registry: CollectorRegistry): Prometheus[F]
  24. def withResponseDurationSecondsHistogramBuckets(responseDurationSecondsHistogramBuckets: NonEmptyList[Double]): Prometheus[F]
  25. def withSampleExemplar(sampleExemplar: F[Option[Map[String, String]]]): Prometheus[F]

Inherited from AnyRef

Inherited from Any

Ungrouped