object Prometheus
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
- Source
- Prometheus.scala
- Alphabetic
- By Inheritance
- Prometheus
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def collectorRegistry[F[_]](implicit F: Sync[F]): Resource[F, CollectorRegistry]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def metricsOps[F[_]](registry: CollectorRegistry, prefix: String = "org_http4s_server", responseDurationSecondsHistogramBuckets: NonEmptyList[Double] = DefaultHistogramBuckets)(implicit arg0: Sync[F]): Resource[F, MetricsOps[F]]
Creates a MetricsOps that supports Prometheus metrics
Creates a MetricsOps that supports Prometheus metrics
- registry
a metrics collector registry
- prefix
a prefix that will be added to all metrics
- def metricsOpsWithExemplars[F[_]](registry: CollectorRegistry, sampleExemplar: F[Option[Map[String, String]]], prefix: String = "org_http4s_server", responseDurationSecondsHistogramBuckets: NonEmptyList[Double] = DefaultHistogramBuckets)(implicit arg0: Sync[F]): Resource[F, MetricsOps[F]]
Creates a MetricsOps that supports Prometheus metrics and records exemplars.
Creates a MetricsOps that supports Prometheus metrics and records exemplars.
Warning: The sampler effect is responsible for producing exemplar labels that are valid for the underlying implementation as errors happening during metric recording will not be handled! For Prometheus version < 1.0, this means the combined length of keys and values may not exceed 128 characters and the parts must adhere to the label regex Prometheus defines.
- registry
a metrics collector registry
- sampleExemplar
an effect that returns the corresponding exemplar labels
- prefix
a prefix that will be added to all metrics
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()