Module Opentelemetry_emitter.Emitter

Emitters.

This is the composable abstraction we use to represent how signals are emitted, from their origin point (a site in user code or library code that was instrumented, and just created a span or log record or metric), down to the actual SDK exporter installed in the application.

exception Closed
type -'a t = {
  1. signal_name : string;
    (*

    Description of what signal is emitted

    *)
  2. enabled : unit -> bool;
    (*

    Return true if emit has a chance of doing something with the signals it's given.

    *)
  3. emit : 'a list -> unit;
    (*

    Emit signals.

    • raises Closed

      if the emitter is closed.

    *)
  4. tick : mtime:Mtime.t -> unit;
    (*

    Call regularly to ensure background work is done. The current monotonic timestamp is passed to improve testability.

    *)
  5. closed : unit -> bool;
    (*

    True if the emitter is already closed. Beware TOCTOU bugs.

    *)
  6. flush_and_close : unit -> unit;
    (*

    Flush internally buffered signals, then close.

    *)
  7. self_metrics : now:Opentelemetry_util.Timestamp_ns.t -> unit -> Opentelemetry_proto.Metrics.metric list;
    (*

    metrics about the emitter itself.

    *)
}

An emitter for values of type 'a.

val enabled : 'a t -> bool
val emit : 'a t -> 'a list -> unit
val tick : 'a t -> mtime:Mtime.t -> unit
val closed : 'a t -> bool
val flush_and_close : 'a t -> unit
val map : ('a -> 'b) -> 'b t -> 'a t

map f emitter returns a new emitter that applies f to signals item-wise before passing them to emitter

val flat_map : ('a list -> 'b list) -> 'b t -> 'a t

map_l f emitter applies f to incoming lists of signals, and emits the resulting list (if non empty)

val tap : ('a -> unit) -> 'a t -> 'a t

tap f e is like e, but every signal is passed to f

val make : ?tick:(mtime:Mtime.t -> unit) -> ?closed:(unit -> bool) -> ?enabled:(unit -> bool) -> ?flush_and_close:(unit -> unit) -> ?self_metrics: (now:Opentelemetry_util.Timestamp_ns.t -> unit -> Opentelemetry_proto.Metrics.metric list) -> signal_name:string -> emit:('a list -> unit) -> unit -> 'a t

make ~emit () is an emitter that calls emit.

val dummy : 'a t

Dummy emitter, doesn't accept or emit anything.