Documentation
¶
Overview ¶
Package ochealth exports health.State data via OpenCensus.
ochealth allows you to take the state from a health server and export the data in it via OpenCensus metrics. For example, to track the readiness of your server over time you can use OpenCensus to export via Prometheus metrics where you can graph and alert on your service not being ready. It also allows you to export version information so you can easily correlate version changes with changes in other metrics making it easier to identify regressions.
The servers in github.com/anz-bank/pkg/health all have a State field. This can be passed to the Register function in this package to have that state provided as OpenCensus metrics.
Two metrics are published by this package: - anz_health_ready - anz_health_version
The "ready" metric tracks the real-time value of the Ready field in the State, exporting false as 0 and true as 1.
The "version" metric is constant - it is exported as 1 and never changes. It is the labels on this that are the part of interest. The fields of the Version in the State are exported as labels on the metric. The current labels are "build_log_url", "commit_hash", "container_tag", "semver" and "repo_url".
The prefix "anz_health" is configurable with the WithPrefix Option that can be passed to Register. The prefix can be removed entirely by using the empty string as a prefix.
Additional labels can be added to the metrics with the WithConstLabels Option. NOTE: This currently panics due to a bug in the OpenCensus Go library. The panic will be removed when https://github.com/census-instrumentation/opencensus-go/pull/1221 is merged and released.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*registerOptions)
Option is used to configure the registration of the health state. The With* functions should be used to obtain options for passing to Register.
func WithConstLabels ¶
func WithConstLabels(labels map[metricdata.LabelKey]metricdata.LabelValue) Option
WithConstLabels returns an Option that adds additional labels with constant values to the metrics published by this package.
func WithPrefix ¶
WithPrefix returns an option that sets the prefix on the metric name published by this package. The default is "anz_health" which can be overidden with this option. The empty string removes the prefix. Any other value will be used as the prefix with an underscore separating the prefix from the base metric name.