ClusterLabs / ha_cluster_exporter

Prometheus exporter for Pacemaker based Linux HA clusters
Apache License 2.0
79 stars 35 forks source link

Instrumented collectors #169

Closed stefanotorresi closed 4 years ago

stefanotorresi commented 4 years ago

This PR adds instrumentation to the exporter itself by introducing a new interface for the existing collectors, called InstrumentableCollector, and wrapping these in a new InstrumentedCollector concrete implementation, which adds the following two metrics to each collector, using a constant label (i.e. a label that never changes in a time series):

# HELP ha_cluster_scrape_duration_seconds Duration of a collector scrape.
# TYPE ha_cluster_scrape_duration_seconds gauge
ha_cluster_scrape_duration_seconds{collector="foo"} 1.234
# HELP ha_cluster_scrape_success Whether a collector succeeded.
# TYPE ha_cluster_scrape_success gauge
ha_cluster_scrape_success{collector="foo"} 1

These metrics take inspiration from node_exporter.

Some significant refactoring was contextually performed to the main run() function, to add some test coverage to it.

Closes #159