How to trace a GenServer’s Execution? Elixir

Malreddy Ankanna
blackode
Published in
4 min readMar 28, 2018

--

Enable tracing using the debug option.

This article is for beginners especially who have been started playing with GenServer .

Today, you are going to build an OTP server and you will trace the server using simple technique. This is not a technique, it is an option while calling the start_link/3 function.

Talk is cheap, lets code it.

What we do here ?

We together implement the STACK server and will trace that server.
As you know stack is a data structure based on the concept of first in last out or last in first out.

I’ll try to keep this as simple as possible with out dwelling in over engineering. Our ultimate goal is to understand the concept.

stack.ex

Create a file stack.ex using your favourite editor. Here, I use vim

$ vim stack.ex

In Elixir, we usually name our module with the name of the file. It is a general convention to avoid confusion. So, create a module named Stack with the following code.

--

--

Malreddy Ankanna
blackode

Programmer & Writer, I write about coding, thoughts, ideas, personal musings, technical articles, and tutorials.https://bio.link/blackode