Configuring Options

Let’s learn how to configure options to handle our logger.

Users can configure options to represent thresholds. These thresholds specify when a healthy logger becomes sick because its message logger gets too long. Some features of these thresholds are as follows:

  • Two of these thresholds specify when to go from cast to call or start shedding messages.

  • Users can also configure thresholds defining when the system goes from sick to healthy. When an unhealthy system has a message queue that shrinks below these thresholds, the logger can stop discarding messages or go back to cast from call.

The logger code then uses that configuration to implement three different modes to implement the cast, call, and shedding modes. They are called :async, :sync, and :discard, respectively.

Now, let’s look at the specific Elixir implementation.

Checking messages

As a general metric for system health, it sometimes helps to look at the number of messages in a processes mailbox. Here’s the code that does that job:

Get hands-on with 1200+ tech skills courses.