metrics

package
v0.0.0-...-60c8855 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IncrementCount

func IncrementCount(metricName string)

Increment Count by 1 for Metric by name

func IncrementCountBy

func IncrementCountBy(metricName string, amount int)

Increment Count by amount for Metric by name

func MeasureSince

func MeasureSince(metricName string, since time.Time)

Measure Time since given for Metric by name

func SetGauge

func SetGauge(metricName string, val float32)

Gauge value for Metric by name

func SetMetricsGlobal

func SetMetricsGlobal(recorder MetricsRecorder)

Public initialization function to initialize the Metrics global. If you're using metrics, this should be called before any goroutines using them are started.

(If you don't care about metrics, you don't need to call this function; nothing will break, since a no-op metrics sink is used by default.)

func SetPrefix

func SetPrefix(prefix string)

Set Prefix for all Metrics collected

Types

type DatadogStatsdRecorder

type DatadogStatsdRecorder struct {
	*StatsdRecorder
	// contains filtered or unexported fields
}

DatadogStatsdRecorder wraps a StatsdRecorder and allows tagging of metrics

func NewDatadogStatsdRecorder

func NewDatadogStatsdRecorder(statsiteEndpoint, namespace, hostname string) (*DatadogStatsdRecorder, error)

func (*DatadogStatsdRecorder) GetTags

func (dd *DatadogStatsdRecorder) GetTags() []metrics.Label

func (*DatadogStatsdRecorder) IncrementCount

func (dd *DatadogStatsdRecorder) IncrementCount(metricName string)

func (*DatadogStatsdRecorder) IncrementCountBy

func (dd *DatadogStatsdRecorder) IncrementCountBy(metricName string, amount int)

func (*DatadogStatsdRecorder) MeasureDurationMS

func (dd *DatadogStatsdRecorder) MeasureDurationMS(metricName string, durationMS float32)

func (*DatadogStatsdRecorder) MeasureSince

func (dd *DatadogStatsdRecorder) MeasureSince(metricName string, since time.Time)

func (*DatadogStatsdRecorder) SetGauge

func (dd *DatadogStatsdRecorder) SetGauge(metricName string, val float32)

func (*DatadogStatsdRecorder) WithTag

func (dd *DatadogStatsdRecorder) WithTag(key, value string) MetricsRecorder

WithTag returns a new DatadogStatsdRecorder that has the tags added to it.

type MetricsRecorder

type MetricsRecorder interface {
	IncrementCount(metricName string)
	IncrementCountBy(metricName string, amount int)
	MeasureSince(metricName string, since time.Time)
	MeasureDurationMS(metricName string, durationMS float32)
	SetGauge(metricName string, val float32)
	SetPrefix(prefix string)
	WithTag(key, value string) MetricsRecorder
}

Public interface for recording metrics.

func WithTag

func WithTag(key, value string) MetricsRecorder

WithTag returns a new MetricsRecorder that has the tags added to it.

type NoopRecorder

type NoopRecorder struct{}

A nop-op MetricsRecorder implementation. For use when real metrics systems are unavailable.

func (*NoopRecorder) IncrementCount

func (*NoopRecorder) IncrementCount(string)

func (*NoopRecorder) IncrementCountBy

func (*NoopRecorder) IncrementCountBy(string, int)

func (*NoopRecorder) MeasureDurationMS

func (*NoopRecorder) MeasureDurationMS(string, float32)

func (*NoopRecorder) MeasureSince

func (*NoopRecorder) MeasureSince(string, time.Time)

func (*NoopRecorder) SetGauge

func (*NoopRecorder) SetGauge(string, float32)

func (*NoopRecorder) SetPrefix

func (*NoopRecorder) SetPrefix(string)

func (*NoopRecorder) WithTag

func (n *NoopRecorder) WithTag(key, value string) MetricsRecorder

type StatsdRecorder

type StatsdRecorder struct {
	*metrics.Metrics
	// contains filtered or unexported fields
}

A MetricsRecorder implementation which is just a wrapper around the go-metrics library, to record to Statsd.

func NewStatsdRecorder

func NewStatsdRecorder(statsiteEndpoint, namespace string) (*StatsdRecorder, error)

Takes a host:port string of the statsite endpoint to write to.

func (*StatsdRecorder) IncrementCount

func (m *StatsdRecorder) IncrementCount(metricName string)

func (*StatsdRecorder) IncrementCountBy

func (m *StatsdRecorder) IncrementCountBy(metricName string, amount int)

func (*StatsdRecorder) MeasureDurationMS

func (m *StatsdRecorder) MeasureDurationMS(metricName string, durationMS float32)

func (*StatsdRecorder) MeasureSince

func (m *StatsdRecorder) MeasureSince(metricName string, since time.Time)

func (*StatsdRecorder) SetGauge

func (m *StatsdRecorder) SetGauge(metricName string, val float32)

func (*StatsdRecorder) SetPrefix

func (m *StatsdRecorder) SetPrefix(prefix string)

func (*StatsdRecorder) WithTag

func (m *StatsdRecorder) WithTag(key, value string) MetricsRecorder

type TeedMetricsRecorder

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

func NewTeedMetricsRecorder

func NewTeedMetricsRecorder(metrics ...MetricsRecorder) *TeedMetricsRecorder

func (*TeedMetricsRecorder) GetMetrics

func (t *TeedMetricsRecorder) GetMetrics() []MetricsRecorder

func (*TeedMetricsRecorder) IncrementCount

func (t *TeedMetricsRecorder) IncrementCount(metricName string)

func (*TeedMetricsRecorder) IncrementCountBy

func (t *TeedMetricsRecorder) IncrementCountBy(metricName string, amount int)

func (*TeedMetricsRecorder) MeasureDurationMS

func (t *TeedMetricsRecorder) MeasureDurationMS(metricName string, durationMS float32)

func (*TeedMetricsRecorder) MeasureSince

func (t *TeedMetricsRecorder) MeasureSince(metricName string, since time.Time)

func (*TeedMetricsRecorder) SetGauge

func (t *TeedMetricsRecorder) SetGauge(metricName string, val float32)

func (*TeedMetricsRecorder) SetPrefix

func (t *TeedMetricsRecorder) SetPrefix(prefix string)

func (*TeedMetricsRecorder) WithTag

func (t *TeedMetricsRecorder) WithTag(key, value string) MetricsRecorder

Jump to

Keyboard shortcuts

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