metrics

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MIT Imports: 21 Imported by: 41

Documentation

Overview

Package metrics contains a type for aggregating and propagating metrics to various services based on configuration.

Index

Constants

View Source
const (
	TypeBlackList  = "blacklist"
	TypeHTTPServer = "http_server"
	TypePrometheus = "prometheus"
	TypeRename     = "rename"
	TypeStatsd     = "statsd"
	TypeWhiteList  = "whitelist"
)

String constants representing each metric type.

Variables

View Source
var Constructors = map[string]TypeSpec{}

Constructors is a map of all metrics types with their specs.

View Source
var (
	ErrInvalidMetricOutputType = errors.New("invalid metrics output type")
)

Errors for the metrics package.

View Source
var (
	ErrTimedOut = errors.New("timed out")
)

Errors for the HTTP type.

Functions

func Descriptions

func Descriptions() string

Descriptions returns a formatted string of collated descriptions of each type.

func OptSetLogger added in v0.14.4

func OptSetLogger(log log.Modular) func(Type)

OptSetLogger sets the logging output to be used by the metrics clients.

func SanitiseConfig

func SanitiseConfig(conf Config) (interface{}, error)

SanitiseConfig returns a sanitised version of the Config, meaning sections that aren't relevant to behaviour are removed.

Types

type Blacklist added in v1.6.0

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

Blacklist is a statistics object that wraps a separate statistics object and only permits statistics that pass through the Blacklist to be recorded.

func (*Blacklist) Close added in v1.6.0

func (h *Blacklist) Close() error

Close stops the Statsd object from aggregating metrics and cleans up resources.

func (*Blacklist) GetCounter added in v1.6.0

func (h *Blacklist) GetCounter(path string) StatCounter

GetCounter returns a stat counter object for a path.

func (*Blacklist) GetCounterVec added in v1.6.0

func (h *Blacklist) GetCounterVec(path string, n []string) StatCounterVec

GetCounterVec returns a stat counter object for a path with the labels discarded.

func (*Blacklist) GetGauge added in v1.6.0

func (h *Blacklist) GetGauge(path string) StatGauge

GetGauge returns a stat gauge object for a path.

func (*Blacklist) GetGaugeVec added in v1.6.0

func (h *Blacklist) GetGaugeVec(path string, n []string) StatGaugeVec

GetGaugeVec returns a stat timer object for a path with the labels discarded.

func (*Blacklist) GetTimer added in v1.6.0

func (h *Blacklist) GetTimer(path string) StatTimer

GetTimer returns a stat timer object for a path.

func (*Blacklist) GetTimerVec added in v1.6.0

func (h *Blacklist) GetTimerVec(path string, n []string) StatTimerVec

GetTimerVec returns a stat timer object for a path with the labels discarded.

func (*Blacklist) HandlerFunc added in v1.6.0

func (h *Blacklist) HandlerFunc() http.HandlerFunc

HandlerFunc returns an http.HandlerFunc for accessing metrics for appropriate child types

func (*Blacklist) SetLogger added in v1.6.0

func (h *Blacklist) SetLogger(log log.Modular)

SetLogger sets the logger used to print connection errors.

type BlacklistConfig added in v1.6.0

type BlacklistConfig struct {
	Paths    []string `json:"paths" yaml:"paths"`
	Patterns []string `json:"patterns" yaml:"patterns"`
	Child    *Config  `json:"child" yaml:"child"`
}

BlacklistConfig allows for the placement of filtering rules to only allow metrics that are not matched to be displayed or retrieved. It has a set of prefixes (direct string comparison) that are checked as well as a set of regular expressions for more precise control over metrics. It also has a metrics configuration that is wrapped by the Blacklist.

func NewBlacklistConfig added in v1.6.0

func NewBlacklistConfig() BlacklistConfig

NewBlacklistConfig returns the default configuration for a Blacklist

func (BlacklistConfig) MarshalJSON added in v1.6.0

func (w BlacklistConfig) MarshalJSON() ([]byte, error)

MarshalJSON prints an empty object instead of nil.

func (BlacklistConfig) MarshalYAML added in v1.6.0

func (w BlacklistConfig) MarshalYAML() (interface{}, error)

MarshalYAML prints an empty object instead of nil.

type Config

type Config struct {
	Type       string           `json:"type" yaml:"type"`
	Prefix     string           `json:"prefix" yaml:"prefix"`
	Blacklist  BlacklistConfig  `json:"blacklist" yaml:"blacklist"`
	HTTP       struct{}         `json:"http_server" yaml:"http_server"`
	Prometheus PrometheusConfig `json:"prometheus" yaml:"prometheus"`
	Rename     RenameConfig     `json:"rename" yaml:"rename"`
	Statsd     StatsdConfig     `json:"statsd" yaml:"statsd"`
	Whitelist  WhitelistConfig  `json:"whitelist" yaml:"whitelist"`
}

Config is the all encompassing configuration struct for all metric output types.

TODO: V2 move field prefix into specific implementations.

func NewConfig

func NewConfig() Config

NewConfig returns a configuration struct fully populated with default values.

func (*Config) UnmarshalJSON added in v1.6.0

func (c *Config) UnmarshalJSON(bytes []byte) error

UnmarshalJSON ensures that when parsing configs that are in a map or slice the default values are still applied.

func (*Config) UnmarshalYAML added in v1.6.0

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML ensures that when parsing configs that are in a map or slice the default values are still applied.

type DudStat

type DudStat struct{}

DudStat implements the Stat interface but doesn't actual do anything.

func (DudStat) Decr

func (d DudStat) Decr(count int64) error

Decr does nothing.

func (DudStat) Incr

func (d DudStat) Incr(count int64) error

Incr does nothing.

func (DudStat) Set added in v0.23.11

func (d DudStat) Set(value int64) error

Set does nothing.

func (DudStat) Timing

func (d DudStat) Timing(delta int64) error

Timing does nothing.

type DudType

type DudType struct {
	ID int
}

DudType implements the Type interface but doesn't actual do anything.

func Noop added in v0.14.5

func Noop() DudType

Noop returns a DudType for discarding metrics.

func (DudType) Close

func (d DudType) Close() error

Close does nothing.

func (DudType) GetCounter

func (d DudType) GetCounter(path string) StatCounter

GetCounter returns a DudStat.

func (DudType) GetCounterVec added in v0.25.0

func (d DudType) GetCounterVec(path string, n []string) StatCounterVec

GetCounterVec returns a DudStat.

func (DudType) GetGauge

func (d DudType) GetGauge(path string) StatGauge

GetGauge returns a DudStat.

func (DudType) GetGaugeVec added in v0.25.0

func (d DudType) GetGaugeVec(path string, n []string) StatGaugeVec

GetGaugeVec returns a DudStat.

func (DudType) GetTimer

func (d DudType) GetTimer(path string) StatTimer

GetTimer returns a DudStat.

func (DudType) GetTimerVec added in v0.25.0

func (d DudType) GetTimerVec(path string, n []string) StatTimerVec

GetTimerVec returns a DudStat.

func (DudType) SetLogger added in v0.14.4

func (d DudType) SetLogger(log log.Modular)

SetLogger does nothing.

type Flat added in v0.13.3

type Flat interface {
	// Flat is an interface for setting metrics via flat paths.
	// Incr increments a metric by an amount.
	Incr(path string, count int64) error

	// Decr decrements a metric by an amount.
	Decr(path string, count int64) error

	// Timing sets a timing metric.
	Timing(path string, delta int64) error

	// Gauge sets a gauge metric.
	Gauge(path string, value int64) error

	// Close stops aggregating stats and cleans up resources.
	Close() error
}

Flat is an interface for setting metrics via flat paths.

type HTTP

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

HTTP is an object with capability to hold internal stats as a JSON endpoint.

func (*HTTP) Close

func (h *HTTP) Close() error

Close stops the HTTP object from aggregating metrics and cleans up resources.

func (*HTTP) GetCounter

func (h *HTTP) GetCounter(path string) StatCounter

GetCounter returns a stat counter object for a path.

func (*HTTP) GetCounterVec added in v0.25.0

func (h *HTTP) GetCounterVec(path string, n []string) StatCounterVec

GetCounterVec returns a stat counter object for a path with the labels discarded.

func (*HTTP) GetGauge

func (h *HTTP) GetGauge(path string) StatGauge

GetGauge returns a stat gauge object for a path.

func (*HTTP) GetGaugeVec added in v0.25.0

func (h *HTTP) GetGaugeVec(path string, n []string) StatGaugeVec

GetGaugeVec returns a stat timer object for a path with the labels discarded.

func (*HTTP) GetTimer

func (h *HTTP) GetTimer(path string) StatTimer

GetTimer returns a stat timer object for a path.

func (*HTTP) GetTimerVec added in v0.25.0

func (h *HTTP) GetTimerVec(path string, n []string) StatTimerVec

GetTimerVec returns a stat timer object for a path with the labels discarded.

func (*HTTP) HandlerFunc

func (h *HTTP) HandlerFunc() http.HandlerFunc

HandlerFunc returns an http.HandlerFunc for accessing metrics as a JSON blob.

func (*HTTP) SetLogger added in v0.14.4

func (h *HTTP) SetLogger(log log.Modular)

SetLogger does nothing.

type Local added in v0.15.3

type Local struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Local is a metrics aggregator that stores metrics locally.

func NewLocal added in v0.15.3

func NewLocal() *Local

NewLocal creates and returns a new Local aggregator.

func (*Local) Close added in v0.15.3

func (l *Local) Close() error

Close stops the Local object from aggregating metrics and cleans up resources.

func (*Local) GetCounter added in v0.15.3

func (l *Local) GetCounter(path string) StatCounter

GetCounter returns a stat counter object for a path.

func (*Local) GetCounterVec added in v0.25.0

func (l *Local) GetCounterVec(path string, n []string) StatCounterVec

GetCounterVec returns a stat counter object for a path with the labels discarded.

func (*Local) GetCounters added in v0.15.3

func (l *Local) GetCounters() map[string]int64

GetCounters returns a map of metric paths to counters.

func (*Local) GetGauge added in v0.15.3

func (l *Local) GetGauge(path string) StatGauge

GetGauge returns a stat gauge object for a path.

func (*Local) GetGaugeVec added in v0.25.0

func (l *Local) GetGaugeVec(path string, n []string) StatGaugeVec

GetGaugeVec returns a stat timer object for a path with the labels discarded.

func (*Local) GetTimer added in v0.15.3

func (l *Local) GetTimer(path string) StatTimer

GetTimer returns a stat timer object for a path.

func (*Local) GetTimerVec added in v0.25.0

func (l *Local) GetTimerVec(path string, n []string) StatTimerVec

GetTimerVec returns a stat timer object for a path with the labels discarded.

func (*Local) GetTimings added in v0.15.3

func (l *Local) GetTimings() map[string]int64

GetTimings returns a map of metric paths to timers.

func (*Local) SetLogger added in v0.15.3

func (l *Local) SetLogger(log log.Modular)

SetLogger does nothing.

type LocalStat added in v0.15.3

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

LocalStat is a representation of a single metric stat. Interactions with this stat are thread safe.

func (*LocalStat) Decr added in v0.15.3

func (l *LocalStat) Decr(count int64) error

Decr decrements a metric by an amount.

func (*LocalStat) Incr added in v0.15.3

func (l *LocalStat) Incr(count int64) error

Incr increments a metric by an amount.

func (*LocalStat) Set added in v0.23.11

func (l *LocalStat) Set(value int64) error

Set sets a gauge metric.

func (*LocalStat) Timing added in v0.15.3

func (l *LocalStat) Timing(delta int64) error

Timing sets a timing metric.

type PromCounter added in v0.23.11

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

PromCounter is a representation of a single metric stat. Interactions with this stat are thread safe.

func (*PromCounter) Incr added in v0.23.11

func (p *PromCounter) Incr(count int64) error

Incr increments a metric by an amount.

type PromCounterVec added in v0.25.0

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

PromCounterVec creates StatCounters with dynamic labels.

func (*PromCounterVec) With added in v0.25.0

func (p *PromCounterVec) With(labelValues ...string) StatCounter

With returns a StatCounter with a set of label values.

type PromGauge

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

PromGauge is a representation of a single metric stat. Interactions with this stat are thread safe.

func (*PromGauge) Decr

func (p *PromGauge) Decr(count int64) error

Decr decrements a metric by an amount.

func (*PromGauge) Incr

func (p *PromGauge) Incr(count int64) error

Incr increments a metric by an amount.

func (*PromGauge) Set added in v0.23.11

func (p *PromGauge) Set(value int64) error

Set sets a gauge metric.

type PromGaugeVec added in v0.25.0

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

PromGaugeVec creates StatGauges with dynamic labels.

func (*PromGaugeVec) With added in v0.25.0

func (p *PromGaugeVec) With(labelValues ...string) StatGauge

With returns a StatGauge with a set of label values.

type PromTiming

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

PromTiming is a representation of a single metric stat. Interactions with this stat are thread safe.

func (*PromTiming) Timing

func (p *PromTiming) Timing(val int64) error

Timing sets a timing metric.

type PromTimingVec added in v0.25.0

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

PromTimingVec creates StatTimers with dynamic labels.

func (*PromTimingVec) With added in v0.25.0

func (p *PromTimingVec) With(labelValues ...string) StatTimer

With returns a StatTimer with a set of label values.

type Prometheus

type Prometheus struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Prometheus is a stats object with capability to hold internal stats as a JSON endpoint.

func (*Prometheus) Close

func (p *Prometheus) Close() error

Close stops the Prometheus object from aggregating metrics and cleans up resources.

func (*Prometheus) GetCounter

func (p *Prometheus) GetCounter(path string) StatCounter

GetCounter returns a stat counter object for a path.

func (*Prometheus) GetCounterVec added in v0.25.0

func (p *Prometheus) GetCounterVec(path string, labelNames []string) StatCounterVec

GetCounterVec returns an editable counter stat for a given path with labels, these labels must be consistent with any other metrics registered on the same path.

func (*Prometheus) GetGauge

func (p *Prometheus) GetGauge(path string) StatGauge

GetGauge returns a stat gauge object for a path.

func (*Prometheus) GetGaugeVec added in v0.25.0

func (p *Prometheus) GetGaugeVec(path string, labelNames []string) StatGaugeVec

GetGaugeVec returns an editable gauge stat for a given path with labels, these labels must be consistent with any other metrics registered on the same path.

func (*Prometheus) GetTimer

func (p *Prometheus) GetTimer(path string) StatTimer

GetTimer returns a stat timer object for a path.

func (*Prometheus) GetTimerVec added in v0.25.0

func (p *Prometheus) GetTimerVec(path string, labelNames []string) StatTimerVec

GetTimerVec returns an editable timer stat for a given path with labels, these labels must be consistent with any other metrics registered on the same path.

func (*Prometheus) HandlerFunc

func (p *Prometheus) HandlerFunc() http.HandlerFunc

HandlerFunc returns an http.HandlerFunc for scraping metrics.

func (*Prometheus) SetLogger added in v0.14.4

func (p *Prometheus) SetLogger(log log.Modular)

SetLogger does nothing.

type PrometheusConfig

type PrometheusConfig struct {
	PushURL      string `json:"push_url" yaml:"push_url"`
	PushInterval string `json:"push_interval" yaml:"push_interval"`
	PushJobName  string `json:"push_job_name" yaml:"push_job_name"`
}

PrometheusConfig is config for the Prometheus metrics type.

func NewPrometheusConfig

func NewPrometheusConfig() PrometheusConfig

NewPrometheusConfig creates an PrometheusConfig struct with default values.

type Rename added in v1.7.0

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

Rename is a statistics object that wraps a separate statistics object and only permits statistics that pass through the whitelist to be recorded.

func (*Rename) Close added in v1.7.0

func (r *Rename) Close() error

Close stops the Statsd object from aggregating metrics and cleans up resources.

func (*Rename) GetCounter added in v1.7.0

func (r *Rename) GetCounter(path string) StatCounter

GetCounter returns a stat counter object for a path.

func (*Rename) GetCounterVec added in v1.7.0

func (r *Rename) GetCounterVec(path string, n []string) StatCounterVec

GetCounterVec returns a stat counter object for a path with the labels discarded.

func (*Rename) GetGauge added in v1.7.0

func (r *Rename) GetGauge(path string) StatGauge

GetGauge returns a stat gauge object for a path.

func (*Rename) GetGaugeVec added in v1.7.0

func (r *Rename) GetGaugeVec(path string, n []string) StatGaugeVec

GetGaugeVec returns a stat timer object for a path with the labels discarded.

func (*Rename) GetTimer added in v1.7.0

func (r *Rename) GetTimer(path string) StatTimer

GetTimer returns a stat timer object for a path.

func (*Rename) GetTimerVec added in v1.7.0

func (r *Rename) GetTimerVec(path string, n []string) StatTimerVec

GetTimerVec returns a stat timer object for a path with the labels discarded.

func (*Rename) HandlerFunc added in v1.7.0

func (r *Rename) HandlerFunc() http.HandlerFunc

HandlerFunc returns an http.HandlerFunc for accessing metrics for appropriate child types

func (*Rename) SetLogger added in v1.7.0

func (r *Rename) SetLogger(log log.Modular)

SetLogger sets the logger used to print connection errors.

type RenameByRegexpConfig added in v1.7.0

type RenameByRegexpConfig struct {
	Pattern string `json:"pattern" yaml:"pattern"`
	Value   string `json:"value" yaml:"value"`
}

RenameByRegexpConfig contains config fields for a rename by regular expression pattern.

type RenameConfig added in v1.7.0

type RenameConfig struct {
	ByRegexp []RenameByRegexpConfig `json:"by_regexp" yaml:"by_regexp"`
	Child    *Config                `json:"child" yaml:"child"`
}

RenameConfig contains config fields for the Rename metric type.

func NewRenameConfig added in v1.7.0

func NewRenameConfig() RenameConfig

NewRenameConfig returns a RenameConfig with default values.

func (RenameConfig) MarshalJSON added in v1.7.0

func (w RenameConfig) MarshalJSON() ([]byte, error)

MarshalJSON prints an empty object instead of nil.

func (RenameConfig) MarshalYAML added in v1.7.0

func (w RenameConfig) MarshalYAML() (interface{}, error)

MarshalYAML prints an empty object instead of nil.

type StatCounter

type StatCounter interface {
	// Incr increments a counter by an amount.
	Incr(count int64) error
}

StatCounter is a representation of a single counter metric stat. Interactions with this stat are thread safe.

type StatCounterVec added in v0.25.0

type StatCounterVec interface {
	// With returns a StatCounter with a set of label values.
	With(labelValues ...string) StatCounter
}

StatCounterVec creates StatCounters with dynamic labels.

type StatGauge

type StatGauge interface {
	// Set sets the value of a gauge metric.
	Set(value int64) error

	// Incr increments a gauge by an amount.
	Incr(count int64) error

	// Decr decrements a gauge by an amount.
	Decr(count int64) error
}

StatGauge is a representation of a single gauge metric stat. Interactions with this stat are thread safe.

type StatGaugeVec added in v0.25.0

type StatGaugeVec interface {
	// With returns a StatGauge with a set of label values.
	With(labelValues ...string) StatGauge
}

StatGaugeVec creates StatGauges with dynamic labels.

type StatTimer

type StatTimer interface {
	// Timing sets a timing metric.
	Timing(delta int64) error
}

StatTimer is a representation of a single timer metric stat. Interactions with this stat are thread safe.

type StatTimerVec added in v0.25.0

type StatTimerVec interface {
	// With returns a StatTimer with a set of label values.
	With(labelValues ...string) StatTimer
}

StatTimerVec creates StatTimers with dynamic labels.

type Statsd

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

Statsd is a stats object with capability to hold internal stats as a JSON endpoint.

func (*Statsd) Close

func (h *Statsd) Close() error

Close stops the Statsd object from aggregating metrics and cleans up resources.

func (*Statsd) GetCounter

func (h *Statsd) GetCounter(path string) StatCounter

GetCounter returns a stat counter object for a path.

func (*Statsd) GetCounterVec added in v0.25.0

func (h *Statsd) GetCounterVec(path string, n []string) StatCounterVec

GetCounterVec returns a stat counter object for a path with the labels discarded.

func (*Statsd) GetGauge

func (h *Statsd) GetGauge(path string) StatGauge

GetGauge returns a stat gauge object for a path.

func (*Statsd) GetGaugeVec added in v0.25.0

func (h *Statsd) GetGaugeVec(path string, n []string) StatGaugeVec

GetGaugeVec returns a stat timer object for a path with the labels discarded.

func (*Statsd) GetTimer

func (h *Statsd) GetTimer(path string) StatTimer

GetTimer returns a stat timer object for a path.

func (*Statsd) GetTimerVec added in v0.25.0

func (h *Statsd) GetTimerVec(path string, n []string) StatTimerVec

GetTimerVec returns a stat timer object for a path with the labels discarded.

func (*Statsd) SetLogger added in v0.14.4

func (h *Statsd) SetLogger(log log.Modular)

SetLogger sets the logger used to print connection errors.

type StatsdConfig

type StatsdConfig struct {
	Address     string `json:"address" yaml:"address"`
	FlushPeriod string `json:"flush_period" yaml:"flush_period"`
	Network     string `json:"network" yaml:"network"`
}

StatsdConfig is config for the Statsd metrics type.

func NewStatsdConfig

func NewStatsdConfig() StatsdConfig

NewStatsdConfig creates an StatsdConfig struct with default values.

type StatsdStat

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

StatsdStat is a representation of a single metric stat. Interactions with this stat are thread safe.

func (*StatsdStat) Decr

func (s *StatsdStat) Decr(count int64) error

Decr decrements a metric by an amount.

func (*StatsdStat) Incr

func (s *StatsdStat) Incr(count int64) error

Incr increments a metric by an amount.

func (*StatsdStat) Set added in v0.23.11

func (s *StatsdStat) Set(value int64) error

Set sets a gauge metric.

func (*StatsdStat) Timing

func (s *StatsdStat) Timing(delta int64) error

Timing sets a timing metric.

type Type

type Type interface {
	// GetCounter returns an editable counter stat for a given path.
	GetCounter(path string) StatCounter

	// GetCounterVec returns an editable counter stat for a given path with
	// labels, these labels must be consistent with any other metrics registered
	// on the same path.
	GetCounterVec(path string, labelNames []string) StatCounterVec

	// GetTimer returns an editable timer stat for a given path.
	GetTimer(path string) StatTimer

	// GetTimerVec returns an editable timer stat for a given path with labels,
	// these labels must be consistent with any other metrics registered on the
	// same path.
	GetTimerVec(path string, labelNames []string) StatTimerVec

	// GetGauge returns an editable gauge stat for a given path.
	GetGauge(path string) StatGauge

	// GetGaugeVec returns an editable gauge stat for a given path with labels,
	// these labels must be consistent with any other metrics registered on the
	// same path.
	GetGaugeVec(path string, labelNames []string) StatGaugeVec

	// SetLogger sets the logging mechanism of the metrics type.
	SetLogger(log log.Modular)

	// Close stops aggregating stats and cleans up resources.
	Close() error
}

Type is an interface for metrics aggregation.

func Combine added in v0.15.3

func Combine(t1, t2 Type) Type

Combine returns a Type implementation that feeds metrics into two underlying Type implementations.

func Namespaced

func Namespaced(t Type, ns string) Type

Namespaced embeds an existing metrics aggregator under a new namespace. The prefix of the embedded aggregator is still the ultimate prefix of metrics.

func New

func New(conf Config, opts ...func(Type)) (Type, error)

New creates a metric output type based on a configuration.

func NewBlacklist added in v1.6.0

func NewBlacklist(config Config, opts ...func(Type)) (Type, error)

NewBlacklist creates and returns a new Blacklist object

func NewHTTP

func NewHTTP(config Config, opts ...func(Type)) (Type, error)

NewHTTP creates and returns a new HTTP object.

func NewPrometheus

func NewPrometheus(config Config, opts ...func(Type)) (Type, error)

NewPrometheus creates and returns a new Prometheus object.

func NewRename added in v1.7.0

func NewRename(config Config, opts ...func(Type)) (Type, error)

NewRename creates and returns a new Rename object

func NewStatsd

func NewStatsd(config Config, opts ...func(Type)) (Type, error)

NewStatsd creates and returns a new Statsd object.

func NewWhitelist added in v1.6.0

func NewWhitelist(config Config, opts ...func(Type)) (Type, error)

NewWhitelist creates and returns a new Whitelist object

func WrapFlat added in v0.13.3

func WrapFlat(f Flat) Type

WrapFlat creates a Type around a Flat implementation.

type TypeSpec added in v1.6.0

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

TypeSpec is a constructor and a usage description for each metric output type.

type Whitelist added in v1.6.0

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

Whitelist is a statistics object that wraps a separate statistics object and only permits statistics that pass through the whitelist to be recorded.

func (*Whitelist) Close added in v1.6.0

func (h *Whitelist) Close() error

Close stops the Statsd object from aggregating metrics and cleans up resources.

func (*Whitelist) GetCounter added in v1.6.0

func (h *Whitelist) GetCounter(path string) StatCounter

GetCounter returns a stat counter object for a path.

func (*Whitelist) GetCounterVec added in v1.6.0

func (h *Whitelist) GetCounterVec(path string, n []string) StatCounterVec

GetCounterVec returns a stat counter object for a path with the labels discarded.

func (*Whitelist) GetGauge added in v1.6.0

func (h *Whitelist) GetGauge(path string) StatGauge

GetGauge returns a stat gauge object for a path.

func (*Whitelist) GetGaugeVec added in v1.6.0

func (h *Whitelist) GetGaugeVec(path string, n []string) StatGaugeVec

GetGaugeVec returns a stat timer object for a path with the labels discarded.

func (*Whitelist) GetTimer added in v1.6.0

func (h *Whitelist) GetTimer(path string) StatTimer

GetTimer returns a stat timer object for a path.

func (*Whitelist) GetTimerVec added in v1.6.0

func (h *Whitelist) GetTimerVec(path string, n []string) StatTimerVec

GetTimerVec returns a stat timer object for a path with the labels discarded.

func (*Whitelist) HandlerFunc added in v1.6.0

func (h *Whitelist) HandlerFunc() http.HandlerFunc

HandlerFunc returns an http.HandlerFunc for accessing metrics for appropriate child types

func (*Whitelist) SetLogger added in v1.6.0

func (h *Whitelist) SetLogger(log log.Modular)

SetLogger sets the logger used to print connection errors.

type WhitelistConfig added in v1.6.0

type WhitelistConfig struct {
	Paths    []string `json:"paths" yaml:"paths"`
	Patterns []string `json:"patterns" yaml:"patterns"`
	Child    *Config  `json:"child" yaml:"child"`
}

WhitelistConfig allows for the placement of filtering rules to only allow select metrics to be displayed or retrieved. It consists of a set of prefixes (direct string comparison) that are checked, and a standard metrics configuration that is wrapped by the whitelist.

func NewWhitelistConfig added in v1.6.0

func NewWhitelistConfig() WhitelistConfig

NewWhitelistConfig returns the default configuration for a whitelist

func (WhitelistConfig) MarshalJSON added in v1.6.0

func (w WhitelistConfig) MarshalJSON() ([]byte, error)

MarshalJSON prints an empty object instead of nil.

func (WhitelistConfig) MarshalYAML added in v1.6.0

func (w WhitelistConfig) MarshalYAML() (interface{}, error)

MarshalYAML prints an empty object instead of nil.

type WithHandlerFunc

type WithHandlerFunc interface {
	HandlerFunc() http.HandlerFunc
}

WithHandlerFunc is an interface for metrics types that can expose their metrics through an HTTP HandlerFunc endpoint. If a Type can be cast into WithHandlerFunc then you should register its endpoint to the an HTTP server.

Jump to

Keyboard shortcuts

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