Packages

Prometheus client for Elixir focused on ease of use.

Current section

Files

Jump to
hercules lib hercules.ex
Raw

lib/hercules.ex

defmodule Hercules do
@moduledoc """
Hercules is a Prometheus client for Elixir focused on ease of use.
"""
alias Hercules.{
Histogram
}
@type metric :: Histogram.t()
@doc """
Registers given Prometheus metric. You need to do this first
before you can record events for this metric name.
You want to call this as early as possible, before your application starts.
"""
@spec new!(metric) :: :ok
def new!(metric) do
erl_module =
case metric do
%Histogram{} ->
:prometheus_histogram
_ ->
raise "Not implemented"
end
args =
metric
|> Map.drop([:__struct__])
|> Map.to_list()
Kernel.apply(erl_module, :new, [args])
end
end