Maxximiliann
Compilation error in file - (ArgumentError) argument error (stdlib) :ets.lookup_element(:hackney_config, :mod_metrics, 2)
(Please note: Elixir Experience Level: Beginner)
iex -S mix
Erlang/OTP 21 [erts-10.2.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Compiling 2 files (.ex)
== Compilation error in file lib/pump.ex ==
** (ArgumentError) argument error
(stdlib) :ets.lookup_element(:hackney_config, :mod_metrics, 2)
/deps/hackney/src/hackney_metrics.erl:27: :hackney_metrics.get_engine/0
/deps/hackney/src/hackney_connect.erl:78: :hackney_connect.create_connection/5
/deps/hackney/src/hackney_connect.erl:47: :hackney_connect.connect/5
/deps/hackney/src/hackney.erl:333: :hackney.request/5
lib/httpoison/base.ex:793: HTTPoison.Base.request/6
lib/httpoison.ex:128: HTTPoison.request!/5
lib/pump.ex:4: (module)
What’s causing this error and what’s the solution?
Marked As Solved
NobbZ
By using defmodule you are creating a module, its body will get evaluated at compile time to eventually become the modules functions and then gets stored to disk.
Those module and the functions within can then be used at runtime to produce values.
Elixirs compilation though can also call function in another module and use the result to produce code that creates functions, so thats what your current code looks like it’s eventually trying to do that.
I’m not sure though if you really get what I’m writing, as I’m not sure how to explain properly, also I’m on the bus crowded with people and I can’t properly think in such an environment…
Also Liked
hubertlepicki
What’s in the pump.ex around line 4 where the error is? 
Maxximiliann
Thanks for your patient and detailed explanation. I used it to rework the code as follows:
def get_trading_activity do
case HTTPoison.get("https://api.wavesplatform.com/v0/pairs") do
{:ok, _} ->
results = HTTPoison.get!("https://api.wavesplatform.com/v0/pairs")
json_into_atoms = Poison.decode!(results.body, keys: :atoms)
#Exclude all pairs with volumeWAVES < 500
Enum.filter(json_into_atoms.data, fn pairs -> pairs.data.volumeWaves >= 500.0 end)
{:error, %HTTPoison.Error{reason: reason}} ->
IO.inspect reason
end
end
Thanks again!
NobbZ
Is there any reason you do that request at compile time?
If you really want to do that, you need to Application.ensure_started/1 for applications you need runtime features off.
Also most of the apps you specified in :extra_applications don’t belong there as they have been inferred by mix anyway because they are in deps.
hubertlepicki
Ah shoot I totally missed that. Yeah, that’s the reason, the applications like HTTpoison are not started at compile time. The whole code probably should be within some function.







