metric

package
v0.0.0-...-f4ec7ef Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Gauge             = "gauge"
	Counter           = "counter"
	CumulativeCounter = "cumcounter"
)

The different types of metrics that are supported

Variables

This section is empty.

Functions

func AddToAll

func AddToAll(metrics *[]Metric, dims map[string]string)

AddToAll adds a map of dimensions to a list of metrics

Types

type CollectorEmission

type CollectorEmission struct {
	Name          string
	EmissionCount uint64
}

CollectorEmission counts collector emissions

type Filter

type Filter struct {
	Name       string            `json:"name"`
	MetricType string            `json:"type"`
	Dimensions map[string]string `json:"dimensions"`
}

Filter provides a struct that can filter a metric by Name (regex), type, dimension (subset of Dimensions)

func NewFilter

func NewFilter(name string, t string, d map[string]string) Filter

NewFilter returns a Filter with compiled regex

func (*Filter) ToJSON

func (f *Filter) ToJSON() string

ToJSON Transforms Filter to JSON

type InternalMetrics

type InternalMetrics struct {
	Counters map[string]float64
	Gauges   map[string]float64
}

InternalMetrics holds the key:value pairs for counters/gauges

func NewInternalMetrics

func NewInternalMetrics() *InternalMetrics

NewInternalMetrics initializes the internal components of InternalMetrics

type Metric

type Metric struct {
	Name       string            `json:"name"`
	MetricType string            `json:"type"`
	Value      float64           `json:"value"`
	Dimensions map[string]string `json:"dimensions"`
	Buffered   bool              `json:"buffered"`
	Time       time.Time         `json:"time"`
}

Metric type holds all the information for a single metric data point. Metrics are generated in collectors and passed to handlers.

func New

func New(name string) Metric

New returns a new metric with name. Default metric type is "gauge" and timestamp is set to now. Value is initialized to 0.0.

func NewExt

func NewExt(name string, typ string, val float64, d map[string]string, t time.Time, b bool) Metric

NewExt provides a more controled creation

func WithValue

func WithValue(name string, value float64) Metric

WithValue returns metric with value of type Gauge

func (*Metric) AddDimension

func (m *Metric) AddDimension(name, value string)

AddDimension adds a new dimension to the Metric.

func (*Metric) AddDimensions

func (m *Metric) AddDimensions(dimensions map[string]string)

AddDimensions adds multiple new dimensions to the Metric.

func (*Metric) DisableBuffering

func (m *Metric) DisableBuffering()

DisableBuffering takes the metric out of buffering (e.g. ZmqBUF)

func (*Metric) EnableBuffering

func (m *Metric) EnableBuffering()

EnableBuffering puts the metric into buffering handlers (e.g. ZmqBUF)

func (*Metric) GetDimensionValue

func (m *Metric) GetDimensionValue(dimension string) (value string, ok bool)

GetDimensionValue returns the value of a dimension if it's set.

func (*Metric) GetDimensions

func (m *Metric) GetDimensions(defaults map[string]string) (dimensions map[string]string)

GetDimensions returns the dimensions of a metric merged with defaults. Defaults win.

func (*Metric) GetTime

func (m *Metric) GetTime() time.Time

GetTime returns the time

func (*Metric) IsFiltered

func (m *Metric) IsFiltered(f Filter) bool

IsFiltered checks if metrics is filtered with a given filter

func (*Metric) IsSubDim

func (m *Metric) IsSubDim(other map[string]string) bool

IsSubDim checks if the 2st map contains all items in the second

func (*Metric) RemoveDimension

func (m *Metric) RemoveDimension(name string)

RemoveDimension removes a dimension from the Metric.

func (*Metric) SetTime

func (m *Metric) SetTime(mtime time.Time)

SetTime to metric

func (*Metric) ToJSON

func (m *Metric) ToJSON() string

ToJSON Transforms metric to JSON

func (*Metric) ZeroValue

func (m *Metric) ZeroValue() bool

ZeroValue is metric zero value

Jump to

Keyboard shortcuts

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