740059a4b4
also add storage of gathered stats
29 lines
616 B
Elixir
29 lines
616 B
Elixir
defmodule Elstat.Adapter.Elixire do
|
|
@behaviour Elstat.Adapter
|
|
|
|
def adapter_spec do
|
|
%{
|
|
db_columns: [:timestamp, :status, :latency]
|
|
}
|
|
end
|
|
|
|
def check(args) do
|
|
addr = args.base_url
|
|
|
|
req_start = :erlang.monotonic_time(:millisecond)
|
|
resp = HTTPoison.get!("#{addr}/api/hello")
|
|
req_end = :erlang.monotonic_time(:millisecond)
|
|
|
|
delta = req_end - req_start
|
|
|
|
{:ok, {:map, %{
|
|
status: resp.status_code == 200,
|
|
latency: delta,
|
|
}}}
|
|
end
|
|
|
|
def transform_val({:map, %{status: status, latency: latency}}) do
|
|
[status, latency]
|
|
end
|
|
|
|
end
|