adapters.elixire: use get/1 instead of get!/1
This commit is contained in:
parent
3b84381b90
commit
884c9f736d
1 changed files with 16 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue