Metric

zio.metrics.Metric
See theMetric companion object
trait Metric[+Type, -In, +Out] extends ZIOAspect[Nothing, Any, Nothing, Any, Nothing, In]

A Metric[In, Out] represents a concurrent metric, which accepts updates of type In, which are aggregated to a stateful value of type Out.

For example, a counter metric would have type Metric[Double, Double], representing the fact that the metric can be updated with doubles (the amount to increment or decrement the counter by), and the state of the counter is a double.

There are five primitive metric types supported by ZIO:

  • Counters
  • Frequencies
  • Gauges
  • Histograms
  • Summaries

The companion object contains constructors for these primitive metrics. All metrics are derived from these primitive metrics.

Attributes

Companion:
object
Graph
Supertypes
trait ZIOAspect[Nothing, Any, Nothing, Any, Nothing, In]
class Object
trait Matchable
class Any
Self type
Metric[Type, In, Out]

Members list

Concise view

Value members

Concrete methods

final def apply[R, E, A1 <: In](zio: ZIO[R, E, A1])(implicit trace: Trace): ZIO[R, E, A1]

Applies the metric computation to the result of the specified effect.

Applies the metric computation to the result of the specified effect.

Attributes

final def contramap[In2](f: In2 => In): Metric[Type, In2, Out]

Returns a new metric that is powered by this one, but which accepts updates of the specified new type, which must be transformable to the input type of this metric.

Returns a new metric that is powered by this one, but which accepts updates of the specified new type, which must be transformable to the input type of this metric.

Attributes

def decrement(implicit numeric: Numeric[In]): UIO[Unit]
Implicitly added by GaugeSyntax
def decrementBy(value: => In)(implicit numeric: Numeric[In]): UIO[Unit]
Implicitly added by GaugeSyntax
final def fromConst(in: => In): Metric[Type, Any, Out]

Returns a new metric that is powered by this one, but which accepts updates of any type, and translates them to updates with the specified constant update value.

Returns a new metric that is powered by this one, but which accepts updates of any type, and translates them to updates with the specified constant update value.

Attributes

def increment(implicit numeric: Numeric[In]): UIO[Unit]
Implicitly added by CounterSyntax
def increment(implicit numeric: Numeric[In]): UIO[Unit]
Implicitly added by GaugeSyntax
def incrementBy(value: => In)(implicit numeric: Numeric[In]): UIO[Unit]
Implicitly added by CounterSyntax
def incrementBy(value: => In)(implicit numeric: Numeric[In]): UIO[Unit]
Implicitly added by GaugeSyntax
final def map[Out2](f: Out => Out2): Metric[Type, In, Out2]

Returns a new metric that is powered by this one, but which outputs a new state type, determined by transforming the state type of this metric by the specified function.

Returns a new metric that is powered by this one, but which outputs a new state type, determined by transforming the state type of this metric by the specified function.

Attributes

final def mapType[Type2](f: Type => Type2): Metric[Type2, In, Out]
final def modify(in: => In)(implicit trace: Trace): UIO[Unit]

Modifies the metric with the specified update message. For example, if the metric were a gauge, the update would increment the method by the provided amount.

Modifies the metric with the specified update message. For example, if the metric were a gauge, the update would increment the method by the provided amount.

Attributes

def set(value: => In): UIO[Unit]
Implicitly added by GaugeSyntax
final def tagged(key: String, value: String): Metric[Type, In, Out]

Returns a new metric, which is identical in every way to this one, except the specified tag will be added to the tags of this metric.

Returns a new metric, which is identical in every way to this one, except the specified tag will be added to the tags of this metric.

Attributes

final def tagged(extraTag: MetricLabel, extraTags: MetricLabel*): Metric[Type, In, Out]

Returns a new metric, which is identical in every way to this one, except the specified tags have been added to the tags of this metric.

Returns a new metric, which is identical in every way to this one, except the specified tags have been added to the tags of this metric.

Attributes

final def tagged(extraTags0: Set[MetricLabel]): Metric[Type, In, Out]

Returns a new metric, which is identical in every way to this one, except the specified tags have been added to the tags of this metric.

Returns a new metric, which is identical in every way to this one, except the specified tags have been added to the tags of this metric.

Attributes

final def taggedWith[In1 <: In](f: In1 => Set[MetricLabel]): Metric[Type, In1, Unit]

Returns a new metric, which is identical in every way to this one, except dynamic tags are added based on the update values. Note that the metric returned by this method does not return any useful information, due to the dynamic nature of the added tags.

Returns a new metric, which is identical in every way to this one, except dynamic tags are added based on the update values. Note that the metric returned by this method does not return any useful information, due to the dynamic nature of the added tags.

Attributes

final def trackAll(in: => In): ZIOAspect[Nothing, Any, Nothing, Any, Nothing, Any]

Returns a ZIOAspect that will update this metric with the specified constant value every time the aspect is applied to an effect, regardless of whether that effect fails or succeeds.

Returns a ZIOAspect that will update this metric with the specified constant value every time the aspect is applied to an effect, regardless of whether that effect fails or succeeds.

Attributes

final def trackDefect(implicit ev: Throwable <:< In): ZIOAspect[Nothing, Any, Nothing, Any, Nothing, Any]

Returns a ZIOAspect that will update this metric with the throwable defects of the effects that it is applied to. To call this method, the input type of the metric must be Throwable.

Returns a ZIOAspect that will update this metric with the throwable defects of the effects that it is applied to. To call this method, the input type of the metric must be Throwable.

Attributes

final def trackDefectWith(f: Throwable => In): ZIOAspect[Nothing, Any, Nothing, Any, Nothing, Any]

Returns a ZIOAspect that will update this metric with the result of applying the specified function to the defect throwables of the effects that the aspect is applied to.

Returns a ZIOAspect that will update this metric with the result of applying the specified function to the defect throwables of the effects that the aspect is applied to.

Attributes

final def trackDuration(implicit ev: Duration <:< In): ZIOAspect[Nothing, Any, Nothing, Any, Nothing, Any]

Returns a ZIOAspect that will update this metric with the duration that the effect takes to execute. To call this method, the input type of the metric must be Duration.

Returns a ZIOAspect that will update this metric with the duration that the effect takes to execute. To call this method, the input type of the metric must be Duration.

Attributes

final def trackDurationWith(f: Duration => In): ZIOAspect[Nothing, Any, Nothing, Any, Nothing, Any]

Returns a ZIOAspect that will update this metric with the duration that the effect takes to execute. To call this method, you must supply a function that can convert the Duration to the input type of this metric.

Returns a ZIOAspect that will update this metric with the duration that the effect takes to execute. To call this method, you must supply a function that can convert the Duration to the input type of this metric.

Attributes

final def trackError: ZIOAspect[Nothing, Any, Nothing, In, Nothing, Any]

Returns a ZIOAspect that will update this metric with the failure value of the effects that it is applied to.

Returns a ZIOAspect that will update this metric with the failure value of the effects that it is applied to.

Attributes

final def trackErrorWith[In2](f: In2 => In): ZIOAspect[Nothing, Any, Nothing, In2, Nothing, Any]

Returns a ZIOAspect that will update this metric with the result of applying the specified function to the error value of the effects that the aspect is applied to.

Returns a ZIOAspect that will update this metric with the result of applying the specified function to the error value of the effects that the aspect is applied to.

Attributes

final def trackSuccess: ZIOAspect[Nothing, Any, Nothing, Any, Nothing, In]

Returns a ZIOAspect that will update this metric with the success value of the effects that it is applied to.

Returns a ZIOAspect that will update this metric with the success value of the effects that it is applied to.

Attributes

final def trackSuccessWith[In2](f: In2 => In): ZIOAspect[Nothing, Any, Nothing, Any, Nothing, In2]

Returns a ZIOAspect that will update this metric with the result of applying the specified function to the success value of the effects that the aspect is applied to.

Returns a ZIOAspect that will update this metric with the result of applying the specified function to the success value of the effects that the aspect is applied to.

Attributes

final def update(in: => In)(implicit trace: Trace): UIO[Unit]

Updates the metric with the specified update message. For example, if the metric were a counter, the update would increment the method by the provided amount.

Updates the metric with the specified update message. For example, if the metric were a counter, the update would increment the method by the provided amount.

Attributes

final def value(implicit trace: Trace): UIO[Out]

Retrieves a snapshot of the value of the metric at this moment in time.

Retrieves a snapshot of the value of the metric at this moment in time.

Attributes

final def withNow[In2](implicit ev: (In2, Instant) <:< In): Metric[Type, In2, Out]
final def zip[Type2, In2, Out2](that: Metric[Type2, In2, Out2])(implicit z1: Zippable[Type, Type2], uz: Unzippable[In, In2], z2: Zippable[Out, Out2]): Metric[Out, In, Out]
Implicitly added by InvariantSyntax

Inherited methods

def >>>[LowerR1, UpperR1, LowerE1, UpperE1, LowerA1, UpperA1 <: In](that: ZIOAspect[LowerR1, UpperR1, LowerE1, UpperE1, LowerA1, UpperA1]): ZIOAspect[LowerR1, UpperR1, LowerE1, UpperE1, LowerA1, UpperA1]

Attributes

Inherited from:
ZIOAspect
def @@[LowerR1, UpperR1, LowerE1, UpperE1, LowerA1, UpperA1 <: In](that: ZIOAspect[LowerR1, UpperR1, LowerE1, UpperE1, LowerA1, UpperA1]): ZIOAspect[LowerR1, UpperR1, LowerE1, UpperE1, LowerA1, UpperA1]

Returns a new aspect that represents the sequential composition of this aspect with the specified one.

Returns a new aspect that represents the sequential composition of this aspect with the specified one.

Attributes

Inherited from:
ZIOAspect
def andThen[LowerR1, UpperR1, LowerE1, UpperE1, LowerA1, UpperA1 <: In](that: ZIOAspect[LowerR1, UpperR1, LowerE1, UpperE1, LowerA1, UpperA1]): ZIOAspect[LowerR1, UpperR1, LowerE1, UpperE1, LowerA1, UpperA1]

Attributes

Inherited from:
ZIOAspect
def flip: ZIOAspect[LowerR, UpperR, LowerA, UpperA, LowerE, UpperE]

Returns a new aspect that flips the behavior it applies to error and success channels. If the old aspect affected success values in some way, then the new aspect will affect error values in the same way.

Returns a new aspect that flips the behavior it applies to error and success channels. If the old aspect affected success values in some way, then the new aspect will affect error values in the same way.

Attributes

Inherited from:
ZIOAspect

Abstract fields

val keyType: Type

The type of the underlying primitive metric. For example, this could be MetricKeyType.Counter or MetricKeyType.Gauge.

The type of the underlying primitive metric. For example, this could be MetricKeyType.Counter or MetricKeyType.Gauge.

Attributes