adapters.elixire: use get/1 instead of get!/1

This commit is contained in:
Luna Mendes 2018-06-27 20:04:01 -03:00
parent 3b84381b90
commit 884c9f736d

View file

@ -11,15 +11,25 @@ defmodule Elstat.Adapter.Elixire do
addr = args.base_url
req_start = :erlang.monotonic_time(:millisecond)
resp = HTTPoison.get!("#{addr}/api/hello")
status = 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,
}}}
case status do
{:ok, resp} ->
{:ok, {:map, %{
status: resp.status_code == 200,
latency: delta
}}}
{:error, reason} ->
{:ok, {:map, %{
status: false,
# use drops to 0 as failure on conn
latency: 0
}}}
end
end
def transform_val({:map, %{status: status, latency: latency}}) do