statsd

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled      bool    `mapstructure:"enabled" default:"false"`
	Address      string  `mapstructure:"address" default:"127.0.0.1:8125"`
	Prefix       string  `mapstructure:"prefix" default:"compassApi"`
	SamplingRate float64 `mapstructure:"sampling_rate" default:"1"`
	Separator    string  `mapstructure:"separator" default:"."`
}

Config represents configuration options for statsd reporter.

type Metric

type Metric struct {
	// contains filtered or unexported fields
}

Metric represents a statsd metric.

func (*Metric) Failure

func (m *Metric) Failure() *Metric

Failure tags the metric as failure.

func (*Metric) Publish

func (m *Metric) Publish()

Publish publishes the metric with collected tags. Intended to be used with defer.

func (*Metric) Success

func (m *Metric) Success() *Metric

Success tags the metric as successful.

func (*Metric) Tag

func (m *Metric) Tag(key, val string) *Metric

Tag adds a tag to the metric.

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

StatsD provides functions for reporting metrics.

func Init

func Init(logger log.Logger, cfg Config) (*Reporter, error)

New validates the config and initializes the statsD client.

func (*Reporter) Close

func (sd *Reporter) Close()

Close closes statsd connection

func (*Reporter) Gauge

func (sd *Reporter) Gauge(name string, value float64) *Metric

Gauge creates and returns a new gauge metric.

func (*Reporter) Histogram

func (sd *Reporter) Histogram(name string, value float64) *Metric

Histogram creates and returns a rate & gauge metric.

func (*Reporter) Incr

func (sd *Reporter) Incr(name string) *Metric

Incr returns a increment counter metric.

func (*Reporter) Timing

func (sd *Reporter) Timing(name string, value time.Duration) *Metric

Timing returns a timer metric.

Jump to

Keyboard shortcuts

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