Meter

org.typelevel.otel4s.metrics.Meter
See theMeter companion object
trait Meter[F[_]]

Attributes

Companion
object
Source
Meter.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

Constructs a batch callback.

Constructs a batch callback.

Batch callbacks allow a single callback to observe measurements for multiple asynchronous instruments.

The callback will be called when the instruments are being observed.

Attributes

Example

val meter: Meter[F] = ???
val server: F[Unit] = ??? // runs the server
val background: Resource[F, Unit] =
 meter.batchCallback.of(
   meter.observableCounter[Long]("counter").createObserver,
   meter.observableUpDownCounter[Double]("up-down-counter").createObserver,
   meter.observableGauge[Double]("gauge").createObserver
 ) { (counter, upDownCounter, gauge) =>
   counter.record(1L) *> upDownCounter.record(2.0) *> gauge.record(3.0)
 }
background.surround(server) // register batch callback and run the server
Source
Meter.scala
def counter[A : MeasurementValue](name: String): Builder[F, A]

Creates a builder of Counter instrument that records values of type A.

Creates a builder of Counter instrument that records values of type A.

The Counter is monotonic. This means the aggregated value is nominally increasing.

Type parameters

A

the type of the measurement. scala.Long and scala.Double are supported out of the box

Value parameters

name

the name of the instrument

Attributes

See also

See upDownCounter for non-monotonic alternative

Note

the A type must be provided explicitly, for example meter.counter[Long] or meter.counter[Double]

Example

val meter: Meter[F] = ???
val doubleCounter: F[Counter[F, Double]] =
 meter.counter[Double]("double-counter").create
val longCounter: F[Counter[F, Long]] =
 meter.counter[Long]("long-counter").create
Source
Meter.scala
def histogram[A : MeasurementValue](name: String): Builder[F, A]

Creates a builder of Histogram instrument that records values of type A.

Creates a builder of Histogram instrument that records values of type A.

Histogram metric data points convey a population of recorded measurements in a compressed format. A histogram bundles a set of events into divided populations with an overall event count and aggregate sum for all events.

Type parameters

A

the type of the measurement. scala.Long and scala.Double are supported out of the box

Value parameters

name

the name of the instrument

Attributes

Note

the A type must be provided explicitly, for example meter.histogram[Long] or meter.histogram[Double]

Example

val meter: Meter[F] = ???
val doubleHistogram: F[Histogram[F, Double]] =
 meter.histogram[Double]("double-histogram").create
val longHistogram: F[Histogram[F, Long]] =
 meter.histogram[Long]("long-histogram").create
Source
Meter.scala

Creates a builder of ObservableCounter instrument that collects values of type A from the given callback.

Creates a builder of ObservableCounter instrument that collects values of type A from the given callback.

The ObservableCounter is monotonic. This means the aggregated value is nominally increasing.

Type parameters

A

the type of the measurement. scala.Long and scala.Double are supported out of the box

Value parameters

name

the name of the instrument

Attributes

See also

See observableUpDownCounter for non-monotonic alternative

Note

the A type must be provided explicitly, for example meter.observableCounter[Long] or meter.observableCounter[Double]

Example

val meter: Meter[F] = ???
val doubleObservableCounter: Resource[F, ObservableCounter] =
 meter
   .observableCounter[Double]("double-counter")
   .create(Sync[F].delay(List(Measurement(1.0))))
val longObservableCounter: Resource[F, ObservableCounter] =
 meter
   .observableCounter[Long]("long-counter")
   .create(Sync[F].delay(List(Measurement(1L))))
Source
Meter.scala

Creates a builder of ObservableGauge instrument that collects values of type A from the given callback.

Creates a builder of ObservableGauge instrument that collects values of type A from the given callback.

Type parameters

A

the type of the measurement. scala.Long and scala.Double are supported out of the box

Value parameters

name

the name of the instrument

Attributes

Note

the A type must be provided explicitly, for example meter.observableGauge[Long] or meter.observableGauge[Double]

Example

val meter: Meter[F] = ???
val doubleGauge: Resource[F, ObservableGauge] =
 meter
   .observableGauge[Double]("double-gauge")
   .create(Sync[F].delay(List(Measurement(1.0))))
val longGauge: Resource[F, ObservableGauge] =
 meter
   .observableGauge[Long]("long-gauge")
   .create(Sync[F].delay(List(Measurement(1L))))
Source
Meter.scala

Creates a builder of ObservableUpDownCounter instrument that collects values of type A from the given callback.

Creates a builder of ObservableUpDownCounter instrument that collects values of type A from the given callback.

The ObservableUpDownCounter is non-monotonic. This means the aggregated value can increase and decrease.

Type parameters

A

the type of the measurement. scala.Long and scala.Double are supported out of the box

Value parameters

name

the name of the instrument

Attributes

See also

See observableCounter for monotonic alternative

Note

the A type must be provided explicitly, for example meter.observableUpDownCounter[Long] or meter.observableUpDownCounter[Double]

the A type must be provided explicitly, for example meter.observableCounter[Long] or meter.observableCounter[Double]

Example

val meter: Meter[F] = ???
val doubleObservableUpDownCounter: Resource[F, ObservableUpDownCounter] =
 meter
   .observableUpDownCounter[Double]("double-up-down-counter")
   .create(Sync[F].delay(List(Measurement(1.0))))
val longObservableUpDownCounter: Resource[F, ObservableUpDownCounter] =
 meter
   .observableUpDownCounter[Long]("long-up-down-counter")
   .create(Sync[F].delay(List(Measurement(1L))))
Source
Meter.scala
def upDownCounter[A : MeasurementValue](name: String): Builder[F, A]

Creates a builder of UpDownCounter instrument that records values of type A.

Creates a builder of UpDownCounter instrument that records values of type A.

The UpDownCounter is non-monotonic. This means the aggregated value can increase and decrease.

Type parameters

A

the type of the measurement. scala.Long and scala.Double are supported out of the box

Value parameters

name

the name of the instrument

Attributes

See also

See counter for monotonic alternative

Note

the A type must be provided explicitly, for example meter.upDownCounter[Long] or meter.upDownCounter[Double]

Example

val meter: Meter[F] = ???
val doubleUpDownCounter: F[UpDownCounter[F, Double]] =
 meter.upDownCounter[Double]("double-up-down-counter").create
val longUpDownCounter: F[UpDownCounter[F, Long]] =
 meter.upDownCounter[Long]("long-up-down-counter").create
Source
Meter.scala