cosmos-sdk: github.com/cosmos/cosmos-sdk/telemetry Index | Files

package telemetry

import "github.com/cosmos/cosmos-sdk/telemetry"

Index

Package Files

metrics.go wrapper.go

Constants

const (
    FormatDefault    = ""
    FormatPrometheus = "prometheus"
    FormatText       = "text"
)

Metrics supported format types.

const (
    MetricKeyBeginBlocker = "begin_blocker"
    MetricKeyEndBlocker   = "end_blocker"
    MetricLabelNameModule = "module"
)

Common metric key constants

func IncrCounter Uses

func IncrCounter(val float32, keys ...string)

IncrCounter provides a wrapper functionality for emitting a counter metric with global labels (if any).

func IncrCounterWithLabels Uses

func IncrCounterWithLabels(keys []string, val float32, labels []metrics.Label)

IncrCounterWithLabels provides a wrapper functionality for emitting a counter metric with global labels (if any) along with the provided labels.

func MeasureSince Uses

func MeasureSince(start time.Time, keys ...string)

MeasureSince provides a wrapper functionality for emitting a a time measure metric with global labels (if any).

func ModuleMeasureSince Uses

func ModuleMeasureSince(module string, start time.Time, keys ...string)

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 Uses

func ModuleSetGauge(module string, val float32, keys ...string)

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 Uses

func NewLabel(name, value string) metrics.Label

func SetGauge Uses

func SetGauge(val float32, keys ...string)

SetGauge provides a wrapper functionality for emitting a gauge metric with global labels (if any).

func SetGaugeWithLabels Uses

func SetGaugeWithLabels(keys []string, val float32, labels []metrics.Label)

SetGaugeWithLabels provides a wrapper functionality for emitting a gauge metric with global labels (if any) along with the provided labels.

type Config Uses

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"`
}

Config defines the configuration options for application telemetry.

type GatherResponse Uses

type GatherResponse struct {
    Metrics     []byte
    ContentType string
}

type Metrics Uses

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.

func New Uses

func New(cfg Config) (*Metrics, error)

func (*Metrics) Gather Uses

func (m *Metrics) Gather(format string) (GatherResponse, error)

Gather collects all registered metrics and returns a GatherResponse where the metrics are encoded depending on the type. Metrics are either encoded via Prometheus or JSON if in-memory.

Package telemetry imports 8 packages (graph) and is imported by 16 packages. Updated 2020-08-01. Refresh now. Tools for package owners.