Fl4m3Ph03n1x
Background
Our app is constantly printing an error message and we have no idea where it is coming from. My objective is to detect which process(es) is receiving the message so I can then trace it using Process.info via a remote shell and find out which module is causing the issue.
Objective
To achieve this, I am following a suggestion given in a previous discussion and I am trying to use recon.
The error message has the following format:
=ERROR REPORT==== 17-Jun-2019::09:29:22.694288 ===
Unexpected message: {#Ref<0.3271557848.1968439297.87877>,badarg}
After reading the documentation of recon_trace I concluded I needed to base my code on the following example, which traces all calls to handle_call for module Mod for all new processes, and those of an existing one registered with gproc:
recon_trace:calls({Mod,handle_call,3}, {10,100}, [{pid, [{via, gproc, Name}, new]}
In order to try the library I decided to go with a simpler approach and just trace 10 calls from anywhere to handle_info, but it errors out:
:recon_trace.calls({:_, handle_info, 2}, 10)
** (CompileError) iex:3: undefined function handle_info/0
(stdlib) lists.erl:1354: :lists.mapfoldl/3
(stdlib) lists.erl:1355: :lists.mapfoldl/3
(stdlib) lists.erl:1354: :lists.mapfoldl/3
Question
I am connection to the application’s terminal via a remote shell and I am trying to run these commands there.
What am I doing wrong?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
NobbZ
You probably want
:handle_info. lower case identifiers are atoms in erlang syntax.Fl4m3Ph03n1x
Errors out with another error:
NobbZ
From recons documentation it seems to me, that the module isn’t allowed to be the wildcard matcher:
Fl4m3Ph03n1x
So, I can’t use
recon_traceto check calls tohandle_infocoming from any processes?How can I use the recon library to achieve my objective? (Is it possible to use it?)
NobbZ
You could use
:code.all_loaded/0to get all loaded modules and iterate over them to check if they exporthandle_info/2and set a trace programatically…Of course this only works if you make sure to load all modules, eg. via starting a release.
kip
Deleted so the future historians will wonder what amazing insight should have been here
(but @NobbZ will know it was because made an totally incorrect statement)
NobbZ
According to the documentation, that has nothing to do with preloading all modules:
Fl4m3Ph03n1x
Thank you everyone for your kind feedback. I have taken @NobbZ code and fixed it into the following (the original version was missing a map):
This allows me to trace the 10 calls to all modules using
handle_info.Now, we can see the following output:
Which confirms this solution is working !
ijunaidfarooq
this results into this..
how to see the trace?