Note: This repository is scheduled for deprecation. Its only active consumer is ocm-controller.
This repository contains shared Go packages used by OCM Kubernetes controllers.
metrics pkg contains a set of MustRegister* functions for registering Prometheus metrics.
The following is an example of usage for some gauges.
First, declare the metric for the controller under metrics package like this:
// ComponentVersionReconciledTotal counts the number times a component version was reconciled.
// [component, version].
var ComponentVersionReconciledTotal = mh.MustRegisterCounterVec(
"ocm_system",
metricsComponent,
"component_version_reconciled_total",
"Number of times a component version was reconciled",
"component", "version",
)Notice, that the comment contains the parameters this metric needs in square brackets.
To use it in code, call:
metrics.ComponentVersionReconciledTotal.WithLabelValues(cv.GetName(), cv.GetVersion()).Inc()The WithLabelValues will correctly align the name and the version parameters. It will panic if the values are
misaligned or not given correctly.
Certain constants are also defined in order to make all metrics uniform across the controllers.
Contribution and feedback are encouraged and always welcome. For more information about how to contribute, see our Contributing Guide.
OCM follows the NeoNephos Code of Conduct.
Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.
