metrics

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertNumeric added in v1.1.0

func ConvertNumeric(val interface{}) float64

func PrefixMetricName added in v1.1.0

func PrefixMetricName(prefix string, name string) string

Types

type HoneycombMetrics

type HoneycombMetrics struct {
	Config            config.Config   `inject:""`
	Logger            logger.Logger   `inject:""`
	UpstreamTransport *http.Transport `inject:"upstreamTransport"`
	Version           string          `inject:"version"`
	// contains filtered or unexported fields
}

func (*HoneycombMetrics) Count added in v1.1.0

func (h *HoneycombMetrics) Count(name string, n interface{})

func (*HoneycombMetrics) Down added in v1.20.0

func (h *HoneycombMetrics) Down(name string)

func (*HoneycombMetrics) Gauge

func (h *HoneycombMetrics) Gauge(name string, val interface{})

func (*HoneycombMetrics) Get added in v1.20.0

func (h *HoneycombMetrics) Get(name string) (float64, bool)

Retrieves the current value of a gauge, constant, counter, or updown as a float64 (even if it's an integer value). Returns 0 if the name isn't found.

func (*HoneycombMetrics) Histogram

func (h *HoneycombMetrics) Histogram(name string, obs interface{})

func (*HoneycombMetrics) Increment added in v1.1.0

func (h *HoneycombMetrics) Increment(name string)

func (*HoneycombMetrics) Register

func (h *HoneycombMetrics) Register(name string, metricType string)

func (*HoneycombMetrics) Start

func (h *HoneycombMetrics) Start() error

func (*HoneycombMetrics) Store added in v1.20.0

func (h *HoneycombMetrics) Store(name string, val float64)

func (*HoneycombMetrics) Up added in v1.20.0

func (h *HoneycombMetrics) Up(name string)

type Metrics

type Metrics interface {
	// Register declares a metric; metricType should be one of counter, gauge, histogram, updown
	Register(name string, metricType string)
	Increment(name string)                  // for counters
	Gauge(name string, val interface{})     // for gauges
	Count(name string, n interface{})       // for counters
	Histogram(name string, obs interface{}) // for histogram
	Up(name string)                         // for updown
	Down(name string)                       // for updown
	Get(name string) (float64, bool)        // for reading back a counter or a gauge
	Store(name string, val float64)         // for storing a rarely-changing value not sent as a metric
}

The Metrics object supports "constants", which are just float values that can be attached to the metrics system. They do not need to be (and should not) be registered in advance; they are just a bucket of key-float pairs that can be used in combination with other metrics.

func GetMetricsImplementation

func GetMetricsImplementation(c config.Config) Metrics

type MetricsPrefixer added in v1.20.0

type MetricsPrefixer struct {
	Metrics Metrics `inject:"metrics"`
	// contains filtered or unexported fields
}

func NewMetricsPrefixer added in v1.20.0

func NewMetricsPrefixer(prefix string) *MetricsPrefixer

func (*MetricsPrefixer) Count added in v1.20.0

func (p *MetricsPrefixer) Count(name string, val interface{})

func (*MetricsPrefixer) Down added in v1.20.0

func (p *MetricsPrefixer) Down(name string)

func (*MetricsPrefixer) Gauge added in v1.20.0

func (p *MetricsPrefixer) Gauge(name string, val interface{})

func (*MetricsPrefixer) Get added in v1.20.0

func (p *MetricsPrefixer) Get(name string) (float64, bool)

func (*MetricsPrefixer) Histogram added in v1.20.0

func (p *MetricsPrefixer) Histogram(name string, obs interface{})

func (*MetricsPrefixer) Increment added in v1.20.0

func (p *MetricsPrefixer) Increment(name string)

func (*MetricsPrefixer) Register added in v1.20.0

func (p *MetricsPrefixer) Register(name string, metricType string)

func (*MetricsPrefixer) Start added in v1.20.0

func (p *MetricsPrefixer) Start() error

func (*MetricsPrefixer) Store added in v1.20.0

func (p *MetricsPrefixer) Store(name string, val float64)

func (*MetricsPrefixer) Up added in v1.20.0

func (p *MetricsPrefixer) Up(name string)

type MockMetrics

type MockMetrics struct {
	Registrations     map[string]string
	CounterIncrements map[string]int
	GaugeRecords      map[string]float64
	Histograms        map[string][]float64
	UpdownIncrements  map[string]int
	Constants         map[string]float64
	// contains filtered or unexported fields
}

MockMetrics collects metrics that were registered and changed to allow tests to verify expected behavior

func (*MockMetrics) Count added in v1.1.0

func (m *MockMetrics) Count(name string, val interface{})

func (*MockMetrics) Down added in v1.20.0

func (m *MockMetrics) Down(name string)

func (*MockMetrics) Gauge

func (m *MockMetrics) Gauge(name string, val interface{})

func (*MockMetrics) Get added in v1.20.0

func (m *MockMetrics) Get(name string) (float64, bool)

func (*MockMetrics) Histogram

func (m *MockMetrics) Histogram(name string, val interface{})

func (*MockMetrics) Increment added in v1.1.0

func (m *MockMetrics) Increment(name string)

func (*MockMetrics) Register

func (m *MockMetrics) Register(name string, metricType string)

func (*MockMetrics) Start

func (m *MockMetrics) Start()

Start initializes all metrics or resets all metrics to zero

func (*MockMetrics) Store added in v1.20.0

func (m *MockMetrics) Store(name string, val float64)

func (*MockMetrics) Up added in v1.20.0

func (m *MockMetrics) Up(name string)

type NullMetrics

type NullMetrics struct{}

NullMetrics discards all metrics

func (*NullMetrics) Count added in v1.1.0

func (n *NullMetrics) Count(name string, val interface{})

func (*NullMetrics) Down added in v1.20.0

func (n *NullMetrics) Down(name string)

func (*NullMetrics) Gauge

func (n *NullMetrics) Gauge(name string, val interface{})

func (*NullMetrics) Get added in v1.20.0

func (n *NullMetrics) Get(name string) (float64, bool)

func (*NullMetrics) Histogram

func (n *NullMetrics) Histogram(name string, obs interface{})

func (*NullMetrics) Increment added in v1.1.0

func (n *NullMetrics) Increment(name string)

func (*NullMetrics) Register

func (n *NullMetrics) Register(name string, metricType string)

func (*NullMetrics) Start

func (n *NullMetrics) Start()

Start initializes all metrics or resets all metrics to zero

func (*NullMetrics) Store added in v1.20.0

func (n *NullMetrics) Store(name string, value float64)

func (*NullMetrics) Up added in v1.20.0

func (n *NullMetrics) Up(name string)

type PromMetrics

type PromMetrics struct {
	Config config.Config `inject:""`
	Logger logger.Logger `inject:""`
	// contains filtered or unexported fields
}

func (*PromMetrics) Count added in v1.1.0

func (p *PromMetrics) Count(name string, n interface{})

func (*PromMetrics) Down added in v1.20.0

func (p *PromMetrics) Down(name string)

func (*PromMetrics) Gauge

func (p *PromMetrics) Gauge(name string, val interface{})

func (*PromMetrics) Get added in v1.20.0

func (p *PromMetrics) Get(name string) (float64, bool)

func (*PromMetrics) Histogram

func (p *PromMetrics) Histogram(name string, obs interface{})

func (*PromMetrics) Increment added in v1.1.0

func (p *PromMetrics) Increment(name string)

func (*PromMetrics) Register

func (p *PromMetrics) Register(name string, metricType string)

Register takes a name and a metric type. The type should be one of "counter", "gauge", or "histogram"

func (*PromMetrics) Start

func (p *PromMetrics) Start() error

func (*PromMetrics) Store added in v1.20.0

func (p *PromMetrics) Store(name string, val float64)

func (*PromMetrics) Up added in v1.20.0

func (p *PromMetrics) Up(name string)

Jump to

Keyboard shortcuts

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