6 Metrics

 

This chapter covers

  • Explaining why the worker needs to collect metrics
  • Defining the metrics
  • Creating a process to collect metrics
  • Implementing a handler on the existing API

Imagine you’re the host at a busy restaurant on a Friday night. You have six servers waiting on customers sitting at tables spread across the room. Each customer at each of those tables has different requirements. One customer might be there to have drinks and appetizers with a group of friends they haven’t seen in a while. Another customer might be there for a full dinner, complete with an appetizer and dessert. Yet another customer might have strict dietary requirements and only eat plant-based food.

Now a new customer walks in. It’s a family of four: two adults and two teenage children. Where do you seat them? Do you place them at the table in the section being served by John, who already has three tables with four customers each? Do you place them at the table in Jill’s section, which has six tables with a single customer each? Or do you place them in Willie’s section, which has a single table with three customers?

6.1 What metrics should we collect?

6.2 Metrics available from the /proc filesystem

6.3 Collecting metrics with goprocinfo

6.4 Exposing the metrics on the API

6.5 Putting it all together

Summary