telemetry

package
v2.0.0-...-94cfcc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
const ServerName = "telemetry"

Variables

View Source
var GlobalLabels = []metrics.Label{} //nolint: ignore // false positive

GlobalLabels defines the set of global labels that will be applied to all metrics emitted using the telemetry package function wrappers.

Functions

func NewLabel

func NewLabel(name, value string) metrics.Label

NewLabel creates a new instance of Label with name and value

Types

type Config

type Config struct {
	// Enable 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.
	Enable bool `` /* 220-byte string literal not displayed */

	// Address defines the API server to listen on
	Address string `mapstructure:"address" toml:"address" comment:"Address defines the metrics server address to bind to."`

	// Prefixed with keys to separate services
	ServiceName string `mapstructure:"service-name" toml:"service-name" comment:"Prefixed with keys to separate services."`

	// Enable prefixing gauge values with hostname
	EnableHostname bool `mapstructure:"enable-hostname" toml:"enable-hostname" comment:"Enable prefixing gauge values with hostname."`

	// Enable adding hostname to labels
	EnableHostnameLabel bool `mapstructure:"enable-hostname-label" toml:"enable-hostname-label" comment:"Enable adding hostname to labels."`

	// Enable adding service to labels
	EnableServiceLabel bool `mapstructure:"enable-service-label" toml:"enable-service-label" comment:"Enable adding service to labels."`

	// PrometheusRetentionTime, when positive, enables a Prometheus metrics sink.
	// It defines the retention duration in seconds.
	PrometheusRetentionTime int64 `` /* 204-byte string literal not displayed */

	// 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 `` /* 257-byte string literal not displayed */

	// MetricsSink defines the type of metrics backend to use.
	MetricsSink string `` /* 126-byte string literal not displayed */

	// StatsdAddr defines the address of a statsd server to send metrics to.
	// Only utilized if MetricsSink is set to "statsd" or "dogstatsd".
	StatsdAddr string `` /* 192-byte string literal not displayed */

	// DatadogHostname defines the hostname to use when emitting metrics to
	// Datadog. Only utilized if MetricsSink is set to "dogstatsd".
	DatadogHostname string `` /* 198-byte string literal not displayed */
}

func DefaultConfig

func DefaultConfig() *Config

type DisplayableSink

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

type GatherResponse struct {
	Metrics     []byte
	ContentType string
}

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.

func NewMetrics

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

NewMetrics creates a new instance of Metrics

func (*Metrics) Gather

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.

type Server

type Server[T transaction.Tx] struct {
	// contains filtered or unexported fields
}

func New

func New[T transaction.Tx](cfg server.ConfigMap, logger log.Logger, enableTelemetry func()) (*Server[T], error)

New creates a new telemetry server.

func (*Server[T]) Config

func (s *Server[T]) Config() any

func (*Server[T]) Name

func (s *Server[T]) Name() string

Name returns the server name.

func (*Server[T]) Start

func (s *Server[T]) Start(ctx context.Context) error

func (*Server[T]) Stop

func (s *Server[T]) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL