Tracing
Explore how to effectively trace and debug Elixir applications using Erlang's built-in tools like :erlang.trace and the :dbg module. Understand how to monitor process messages safely in staging or production settings and configure custom trace handlers to avoid system overload. This lesson guides you in applying structured tracing to maintain stability while diagnosing live systems.
We'll cover the following...
Debugging in Elixir
When it comes to debugging, Elixir developers have two main options. We can do either of the two:
-
Use the debugger GUI that ships with Erlang
-
The new
IEx.break!Elixir tools.
Debuggers let us stop the execution of one or more processes and inspect their environment, but debugging is clearly not a good match for a production system. If we interrupt an important process in our application while debugging, we could start to accumulate requests, leading to timeouts or even restarts. In the end, our email inbox may begin to rapidly fill.
Because the risks of interacting with live systems and security concerns are acute, many companies simply do not give developers access to production nodes except under special circumstances. Even if we work at one of those companies, these next few useful lessons can help us debug systems in staging environments or under load tests.
To debug such systems, we need tools that are lightweight and have little to no effect on the system operations. As one would expect from a technology that has been battle-tested for decades, the Erlang VM has ...