Tinkex.Metrics (Tinkex v0.3.4)
View SourceLightweight metrics aggregation for Tinkex telemetry events.
The server subscribes to [:tinkex, :http, :request, :stop] and keeps
counters for successes/failures plus latency histograms. Public helpers allow
recording custom counters, gauges, and histograms for experiment tracking.
Summary
Functions
Block until the server has processed all prior casts.
Telemetry handler entrypoint.
Increment a counter metric by the provided delta (default: 1).
Record a histogram sample (value in milliseconds).
Reset all metrics state.
Set a gauge to a specific value.
Return a snapshot of counters, gauges, and histograms.
Start the metrics server.
Types
@type metric_name() :: atom()
@type snapshot() :: %{ counters: %{optional(metric_name()) => number()}, gauges: %{optional(metric_name()) => number()}, histograms: %{optional(metric_name()) => histogram_snapshot()} }
Functions
@spec flush() :: :ok
Block until the server has processed all prior casts.
Telemetry handler entrypoint.
@spec increment(metric_name(), number()) :: :ok
Increment a counter metric by the provided delta (default: 1).
@spec record_histogram(metric_name(), number()) :: :ok
Record a histogram sample (value in milliseconds).
@spec reset() :: :ok
Reset all metrics state.
@spec set_gauge(metric_name(), number()) :: :ok
Set a gauge to a specific value.
@spec snapshot() :: snapshot()
Return a snapshot of counters, gauges, and histograms.
@spec start_link(keyword()) :: GenServer.on_start()
Start the metrics server.
Options:
:enabled- turn metrics on/off (defaults to application env, true):latency_buckets- histogram buckets in milliseconds