In “The Soul of Erlang and Elixir”, Saša Jurić had some custom code to trace function invocations in a process and return the first 50 invocations or all invocations in 1 second, whichever comes first. But he didn’t show the code behind the function he called.
How would you do that? (My guess is that it uses
[Turning on the @sasajuric Batman spotlight]
The code is available here. It’s made exclusively for that demo, so it’s not the prettiest nor particularly safe You’ll probably be better off using recon or redbug in real prod.
Just reading it, I have no idea why I’m calling
trace twice, returning an error if the second one fails. A single
trace call followed by a call to
trace_pattern should work.
We need an “Elixir in Anger”
would you please point into the direction of how you would do that with recon or redbug in prod?
Both of these tools have some form of such safe guards (though IIRC not exactly the same). A good place to learn more would be docs:
There’s also Extrace, which wraps recon to log elixir terms instead of erlang ones.