elstat/lib/adapters/elixire.ex

32 lines
677 B
Elixir
Raw Normal View History

2018-06-11 07:24:16 +00:00
defmodule Elstat.Adapter.Elixire do
@behaviour Elstat.Adapter
use GenServer
require Logger
def start_link(service_opts) do
GenServer.start_link(__MODULE__, service_opts, [])
end
def init(service_opts) do
Logger.info("Elixire adapter started with #{inspect service_opts}")
{:ok, %{}}
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,
2018-06-11 20:42:40 +00:00
latency: delta,
2018-06-11 07:24:16 +00:00
}}}
end
end