Documentation ¶
Index ¶
- Constants
- func IncrCounter(val float32, keys ...string)
- func IncrCounterWithLabels(keys []string, val float32, labels []metrics.Label)
- func IsTelemetryEnabled() bool
- func MeasureSince(start time.Time, keys ...string)
- func ModuleMeasureSince(module string, start time.Time, keys ...string)
- func ModuleSetGauge(module string, val float32, keys ...string)
- func NewLabel(name, value string) metrics.Label
- func Now() time.Time
- func SetGauge(val float32, keys ...string)
- func SetGaugeWithLabels(keys []string, val float32, labels []metrics.Label)
- type Config
- type DisplayableSink
- type GatherResponse
- type Metrics
Constants ¶
const ( FormatDefault = "" FormatPrometheus = "prometheus" FormatText = "text" ContentTypeText = `text/plain; version=` + expfmt.TextVersion + `; charset=utf-8` MetricSinkInMem = "mem" MetricSinkStatsd = "statsd" MetricSinkDogsStatsd = "dogstatsd" )
Metrics supported format types.
const ( MetricKeyBeginBlocker = "begin_blocker" MetricKeyEndBlocker = "end_blocker" MetricKeyPrepareCheckStater = "prepare_check_stater" MetricKeyPrecommiter = "precommiter" MetricLabelNameModule = "module" )
Common metric key constants
Variables ¶
This section is empty.
Functions ¶
func IncrCounter ¶
IncrCounter provides a wrapper functionality for emitting a counter metric with global labels (if any).
func IncrCounterWithLabels ¶
IncrCounterWithLabels provides a wrapper functionality for emitting a counter metric with global labels (if any) along with the provided labels.
func IsTelemetryEnabled ¶ added in v0.50.6
func IsTelemetryEnabled() bool
IsTelemetryEnabled provides controlled access to check if telemetry is enabled.
func MeasureSince ¶
MeasureSince provides a wrapper functionality for emitting a time measure metric with global labels (if any).
func ModuleMeasureSince ¶
ModuleMeasureSince provides a short hand method for emitting a time measure metric for a module with a given set of keys. If any global labels are defined, they will be added to the module label.
func ModuleSetGauge ¶
ModuleSetGauge provides a short hand method for emitting a gauge metric for a module with a given set of keys. If any global labels are defined, they will be added to the module label.
func NewLabel ¶
func NewLabel(name, value string) metrics.Label
NewLabel creates a new instance of Label with name and value
func Now ¶ added in v0.50.6
Now return the current time if telemetry is enabled or a zero time if it's not
func SetGauge ¶
SetGauge provides a wrapper functionality for emitting a gauge metric with global labels (if any).
func SetGaugeWithLabels ¶
SetGaugeWithLabels provides a wrapper functionality for emitting a gauge metric with global labels (if any) along with the provided labels.
Types ¶
type Config ¶
type Config struct { // Prefixed with keys to separate services ServiceName string `mapstructure:"service-name"` // Enabled enables the application telemetry functionality. When enabled, // an in-memory sink is also enabled by default. Operators may also enabled // other sinks such as Prometheus. Enabled bool `mapstructure:"enabled"` // Enable prefixing gauge values with hostname EnableHostname bool `mapstructure:"enable-hostname"` // Enable adding hostname to labels EnableHostnameLabel bool `mapstructure:"enable-hostname-label"` // Enable adding service to labels EnableServiceLabel bool `mapstructure:"enable-service-label"` // PrometheusRetentionTime, when positive, enables a Prometheus metrics sink. // It defines the retention duration in seconds. PrometheusRetentionTime int64 `mapstructure:"prometheus-retention-time"` // GlobalLabels defines a global set of name/value label tuples applied to all // metrics emitted using the wrapper functions defined in telemetry package. // // Example: // [["chain_id", "cosmoshub-1"]] GlobalLabels [][]string `mapstructure:"global-labels"` // MetricsSink defines the type of metrics backend to use. MetricsSink string `mapstructure:"metrics-sink" default:"mem"` // StatsdAddr defines the address of a statsd server to send metrics to. // Only utilized if MetricsSink is set to "statsd" or "dogstatsd". StatsdAddr string `mapstructure:"statsd-addr"` // DatadogHostname defines the hostname to use when emitting metrics to // Datadog. Only utilized if MetricsSink is set to "dogstatsd". DatadogHostname string `mapstructure:"datadog-hostname"` }
Config defines the configuration options for application telemetry.
type DisplayableSink ¶ added in v0.50.2
type DisplayableSink interface {
DisplayMetrics(resp http.ResponseWriter, req *http.Request) (any, error)
}
DisplayableSink is an interface that defines a method for displaying metrics.
type GatherResponse ¶
GatherResponse is the response type of registered metrics
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics defines a wrapper around application telemetry functionality. It allows metrics to be gathered at any point in time. When creating a Metrics object, internally, a global metrics is registered with a set of sinks as configured by the operator. In addition to the sinks, when a process gets a SIGUSR1, a dump of formatted recent metrics will be sent to STDERR.