Module Opentelemetry.Meter_provider

val get : unit -> Meter.t
val set : Meter.t -> unit
val clear : unit -> unit
val get_meter : ?name:string -> ?version:string -> ?attrs:(string * [< Opentelemetry_core.Value.t ]) list -> ?__MODULE__:string -> unit -> Meter.t

Get a meter pre-configured with a fixed set of attributes added to every metric it emits, forwarding to the current global meter. Intended to be called once at the top of a library module.

  • parameter name

    instrumentation scope name (recorded as otel.scope.name)

  • parameter version

    instrumentation scope version (recorded as otel.scope.version)

  • parameter __MODULE__

    the OCaml module name, typically the __MODULE__ literal (recorded as code.namespace)

  • parameter attrs

    additional fixed attributes

val emit : Opentelemetry_core.Metrics.t -> unit

Emit with current meter

val emit_l : Opentelemetry_core.Metrics.t list -> unit

Emit a list of metrics with current meter

val default_meter : Meter.t

A Meter.t that lazily reads the global at emit time

val set_min_interval : Mtime.span -> unit

Set the global minimum interval between two periodic collections (default 30s), clamped to at least 100ms. Affects the global meter provider and every add_periodic_collection that didn't pass its own min_interval.

val collect_and_emit : Meter.t -> unit

Collect all instruments and callbacks, and emit the result into m. Does nothing if m is disabled.

val add_periodic_collection : ?min_interval:Mtime.span Opentelemetry_atomic.Atomic.t -> Meter.t Opentelemetry_atomic.Atomic.t -> unit

add_periodic_collection meter registers a tick callback that periodically collects all instruments (see Meter.collect) and emits them into the current value of meter, if it is enabled.

The global meter provider is already registered this way, so this is only needed to export metrics to an additional destination.

  • parameter min_interval

    minimum interval between collections, read at each tick. Defaults to the global interval, so later calls to set_min_interval apply. A custom atomic is not clamped.

  • since 0.92