metrics

package
v3.0.0-rc9+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 6 Imported by: 63

Documentation

Overview

Package metrics provides storage for metrics being recorded by mtail programs.

Index

Constants

View Source
const (
	Int   = datum.Int
	Float = datum.Float
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind int

Kind enumerates the types of metrics supported.

const (
	Counter Kind
	// Gauge is a Kind that can take on any value, and may be set
	// discontinuously from its previous value.
	Gauge
	// Timer is a specialisation of Gauge that can be used to store time
	// intervals, such as latency and durations.  It enables certain behaviour
	// in exporters that handle time intervals such as StatsD.
	Timer
)

func (Kind) String

func (m Kind) String() string

type LabelSet

type LabelSet struct {
	Labels map[string]string
	Datum  datum.Datum
}

LabelSet is an object that maps the keys of a Metric to the labels naming a Datum, for use when enumerating Datums from a Metric.

type LabelValue

type LabelValue struct {
	Labels []string `json:",omitempty"`
	Value  datum.Datum
}

LabelValue is an object that names a Datum value with a list of label strings.

func (*LabelValue) String

func (lv *LabelValue) String() string

func (*LabelValue) UnmarshalJSON

func (lv *LabelValue) UnmarshalJSON(b []byte) error

type Metric

type Metric struct {
	sync.RWMutex
	Name        string // Name
	Program     string // Instantiating program
	Kind        Kind
	Type        datum.Type
	Hidden      bool          `json:",omitempty"`
	Keys        []string      `json:",omitempty"`
	LabelValues []*LabelValue `json:",omitempty"`
	Source      string        `json:"-"`
}

Metric is an object that describes a metric, with its name, the creator and owner program name, its Kind, a sequence of Keys that may be used to add dimension to the metric, and a list of LabelValues that contain data for labels in each dimension of the Keys.

func NewMetric

func NewMetric(name string, prog string, kind Kind, typ datum.Type, keys ...string) *Metric

NewMetric returns a new empty metric of dimension len(keys).

func (*Metric) EmitLabelSets

func (m *Metric) EmitLabelSets(c chan *LabelSet)

EmitLabelSets enumerates the LabelSets corresponding to the LabelValues of a Metric. It emits them onto the provided channel, then closes the channel to signal completion.

func (*Metric) GetDatum

func (m *Metric) GetDatum(labelvalues ...string) (d datum.Datum, err error)

GetDatum returns the datum named by a sequence of string label values from a Metric. If the sequence of label values does not yet exist, it is created.

func (*Metric) RemoveDatum

func (m *Metric) RemoveDatum(labelvalues ...string) error

func (*Metric) SetSource

func (m *Metric) SetSource(source string)

func (*Metric) String

func (m *Metric) String() string

type Store

type Store struct {
	sync.RWMutex
	Metrics map[string][]*Metric
}

Store contains Metrics.

func NewStore

func NewStore() (s *Store)

func (*Store) Add

func (s *Store) Add(m *Metric) error

Add is used to add one metric to the Store.

func (*Store) ClearMetrics

func (s *Store) ClearMetrics()

ClearMetrics empties the store of all metrics.

func (*Store) MarshalJSON

func (s *Store) MarshalJSON() (b []byte, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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