Skip to content

metrics: call Statfs once per collection of disk metric

Administrator requested to merge k/20220824-metric into main

Created by: keegancsmith

Currently everytime we collect prometheus metrics we call statfs twice, once to calculate the available space and another to calculate the total space. However, we can reuse the statfs call. The pattern implemented here is the same used by the offical prometheus client to interact with go's stdlib metrics.

The motivation of this PR is not that statfs is a bottleneck, but rather to explore this pattern for a more complicated metric which will export many values from a single syscall.

Test Plan: the unit tests explicitly exercise metric collection for disk space.

Merge request reports

Loading