Visualize.Feed.Telemetry (Visualize v0.4.1)

Copy Markdown View Source

An in-process :telemetry provider: a collector over Telemetry.Metrics definitions, one push feed per metric (spec/08 ยง11.6, D-140).

start_link(metrics: definitions) attaches one handler for the definitions' events and collects. A definition is read by its fields โ€” name, event_name, measurement, tags, tag_values, keep, unit, description โ€” and its struct's name, so this library takes no dependency on telemetry_metrics. :telemetry itself is optional: without it the module compiles and the provider is never started.

Each metric is a feed (feeds/1, feed/2) whose rows are %{t: DateTime, value: v} plus the metric's tags, and whose schema says so: t the window field, a :time field of DateTimes; value labelled with the definition's description (else its name), in the definition's unit as a UCUM code (Visualize.Unit.from_telemetry/1) with the quantity it implies, each tag a category. A counter's value is the count so far for its tags and a sum's the running total; a last value's, a summary's and a distribution's the measurement.

The collector stamps every row on receipt with its own clock, strictly increasing, and keeps the newest keep: rows of each metric. It honours a window of DateTime bounds and pushes: every every: milliseconds each subscriber gets the rows new since the last flush, its schema sent first at subscription.

Summary

Functions

Returns a specification to start this module under a supervisor.

One metric's feed, by its dotted name. A name the collector lacks answers {:error, {:unknown_metric, name}}.

Each metric's feed, by its dotted name ("vm.memory.total").

Every subscriber sent the rows new since the last flush, now.

The collector over metrics:, a list of Telemetry.Metrics definitions, attached. Options: name:, keep: (rows kept per metric, 10_000), every: (the push interval in milliseconds, 1000; nil pushes only on flush/1) and clock: (a function of no argument answering microseconds, System.os_time(:microsecond) by default).

Types

t()

@type t() :: %Visualize.Feed.Telemetry{metric: String.t(), server: GenServer.server()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

feed(server, name)

@spec feed(GenServer.server(), String.t()) :: t()

One metric's feed, by its dotted name. A name the collector lacks answers {:error, {:unknown_metric, name}}.

feeds(server)

@spec feeds(GenServer.server()) :: %{required(String.t()) => t()}

Each metric's feed, by its dotted name ("vm.memory.total").

flush(server)

@spec flush(GenServer.server()) :: :ok

Every subscriber sent the rows new since the last flush, now.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

The collector over metrics:, a list of Telemetry.Metrics definitions, attached. Options: name:, keep: (rows kept per metric, 10_000), every: (the push interval in milliseconds, 1000; nil pushes only on flush/1) and clock: (a function of no argument answering microseconds, System.os_time(:microsecond) by default).