metrics

package
Version: v0.0.0-...-d303657 Latest Latest
Warning

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

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datum

type Datum struct {
	Value int64
	Time  int64 // nanoseconds since unix epoch
}

Datum describes a LabelSet's or LabelValue's value at a given timestamp.

func (*Datum) Get

func (d *Datum) Get() int64

Get returns the value of the Datum.

func (*Datum) IncBy

func (d *Datum) IncBy(delta int64, timestamp time.Time)

IncBy implements the Incrementable interface for a Datum.

func (*Datum) Set

func (d *Datum) Set(value int64, timestamp time.Time)

Set implements the Settable interface for a Datum.

func (*Datum) String

func (d *Datum) String() string

type Incrementable

type Incrementable interface {
	IncBy(delta int64, ts time.Time)
}

Incrementable describes an interface for Counter Kinds, that must be nondecreasing.

type Kind

type Kind int

Kind enumerates the types of metrics supported.

const (

	// Counter is a Kind that is nondecreasing, typically only
	// incrementable.
	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
}

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
}

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

func (*LabelValue) String

func (lv *LabelValue) String() string

type Metric

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

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, 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, err error)

GetDatum returns the datum named by a sequence of string label values from a Metric.

func (*Metric) String

func (m *Metric) String() string

type Metrics

type Metrics []*Metric

Metrics defines a Sortable type for a slice of metrics.

func (Metrics) Len

func (ms Metrics) Len() int

func (Metrics) Less

func (ms Metrics) Less(i, j int) bool

func (Metrics) Swap

func (ms Metrics) Swap(i, j int)

type Settable

type Settable interface {
	Set(value int64, ts time.Time)
}

Settable describes an interface for Gauge Kinds, that can be set to any value discontinuously from its previous.

type Store

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

Store contains Metrics.

func NewStore

func NewStore() (s *Store)

func (*Store) Add

func (ms *Store) Add(m ...*Metric)

Add is used to add one or more metrics in the Store.

func (*Store) ClearMetrics

func (ms *Store) ClearMetrics()

ClearMetrics empties the store of all metrics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL