Collect Measurements using StatsD


We can use a number of different tools to take measurements in our code. A commonly used tool is StatsD, and that’s what we’ll use throughout this course. StatsD is a daemon that aggregates statistics. It takes measurements sent by our application and aggregates them into other back-ends that collect the stats. Many APMs provide a StatsD back-end integration; this makes StatsD a great choice for collecting measurements.

There are other tools we can use to collect measurements. StatsD is commonly used and easy to understand. If we prefer a different tool, then we should use that. The important thing is that we are collecting measurements.

It is easy to get started with StatsD in Elixir by using the Statix library. This library has a simple interface with functions that correspond to StatsD measurement types. We’ll use Statix in this course to capture measurements in our application.

Let’s capture various measurements in our HelloSockets application by using Statix and a local StatsD server. We’ll use a fake StatsD server for development that simply logs any packets to the Elixir application console.

Let’s start by adding Statix and a fake StatsD logger to our application.

Get hands-on with 1200+ tech skills courses.