Encodes metric families, as Sovite.Metrics.collect/1 returns them, in
the Prometheus text exposition format, version 0.0.4.
Serve the result with content_type/0 as the Content-Type.
Summary
Functions
@spec content_type() :: String.t()
Returns the Content-Type of the format.
@spec format([Sovite.Metrics.family()]) :: iodata()
Encodes families as iodata.
Each family gets a # HELP line, unless it has no help text, and a
# TYPE line, then its samples. Histograms get a _bucket sample for
each bound, plus le="+Inf" with the count, and _sum and _count
samples. Labels are written sorted by name. When families share a name,
only the first is written.
iex> Sovite.Metrics.Prometheus.format([
...> %{name: "mails_total", type: :counter, help: "Mails received.",
...> samples: [{%{"queue" => "incoming"}, 3}]}
...> ]) |> IO.iodata_to_binary()
~S'''
# HELP mails_total Mails received.
# TYPE mails_total counter
mails_total{queue="incoming"} 3
'''