Documentation ¶
Overview ¶
Package otelhealth exports health.State data via OpenTelemetry.
otelhealth allows you to take the state from a health server and export the data in it via OpenTelemetry metrics. For example, to track the readiness of your server over time you can use OpenTelemetry 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 OpenTelemetry 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.
Index ¶
Constants ¶
const ( // CommitHash is the git hash. CommitHash = otelAttribute.Key("commit_hash") // BuildLogURL is the url for the build log. BuildLogURL = otelAttribute.Key("build_log_url") // ContainerTag is the tag of container. ContainerTag = otelAttribute.Key("container_tag") // RepoURL is the url of the github repository. RepoURL = otelAttribute.Key("repo_url") // Semver is the version. Semver = otelAttribute.Key("semver") )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Int64Counter ¶
Int64Counter is the interface for otel `metric.Int64Counter` interface.
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[otelAttribute.Key]otelAttribute.Value) 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.