metrics

package
v0.0.0-...-b28dce8 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package metrics implements data types for probes generated data.

Package metrics implements data types for probes generated data.

Package metrics implements data types for probes generated data.

Package metrics implements data types for probes generated data.

Package metrics implements data types for probes generated data.

Index

Constants

View Source
const (
	// CUMULATIVE metrics accumulate with time and are usually used to
	// represent counters, e.g. number of requests.
	CUMULATIVE = iota
	// GAUGE metrics are used to represent values at a certain point of
	// time, e.g. pending queries.
	GAUGE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicInt

type AtomicInt struct {

	// If Str is defined, this is method used to convert AtomicInt into a string.
	Str func(int64) string
	// contains filtered or unexported fields
}

AtomicInt implements NumValue with int64 storage and atomic operations. If concurrency-safety is not a requirement, e.g. for use in already mutex protected map, you could use Int.

func NewAtomicInt

func NewAtomicInt(i int64) *AtomicInt

NewAtomicInt returns a new AtomicInt

func (*AtomicInt) Add

func (i *AtomicInt) Add(val Value) error

Add adds a Value to the receiver AtomicInt. If Value is not AtomicInt, an error is returned. It's part of the Value interface.

func (*AtomicInt) AddFloat64

func (i *AtomicInt) AddFloat64(f float64)

AddFloat64 adds a float64 to the receiver Int.

func (*AtomicInt) AddInt64

func (i *AtomicInt) AddInt64(ii int64)

AddInt64 adds an int64 to the receiver Int.

func (*AtomicInt) Float64

func (i *AtomicInt) Float64() float64

Float64 returns the stored int64 as a float64

func (*AtomicInt) Inc

func (i *AtomicInt) Inc()

Inc increments the receiver AtomicInt by one. It's part of the NumValue interface.

func (*AtomicInt) IncBy

func (i *AtomicInt) IncBy(delta NumValue)

IncBy increments the receiver AtomicInt by "delta" NumValue. It's part of the NumValue interface.

func (*AtomicInt) Int64

func (i *AtomicInt) Int64() int64

Int64 returns the stored int64

func (*AtomicInt) String

func (i *AtomicInt) String() string

String returns the string representation of AtomicInt. It's part of the Value interface.

type EventMetrics

type EventMetrics struct {
	Timestamp time.Time
	Kind      Kind
	// contains filtered or unexported fields
}

EventMetrics respresents metrics associated with a particular time event.

func NewEventMetrics

func NewEventMetrics(ts time.Time) *EventMetrics

NewEventMetrics return a new EventMetrics object with internals maps initialized.

func (*EventMetrics) AddLabel

func (em *EventMetrics) AddLabel(name string, val string) *EventMetrics

AddLabel adds a label (name & value) into the receiver EventMetrics. If a label with the same name exists already, new label is ignored. AddLabel returns the receiver EventMetrics to allow for the chaining of these calls, for example:

em := metrics.NewEventMetrics(time.Now()).
	AddMetric("sent", &prr.sent).
	AddLabel("ptype", "http").
	AddLabel("dst", target)

func (*EventMetrics) AddMetric

func (em *EventMetrics) AddMetric(name string, val Value) *EventMetrics

AddMetric adds a metric (name & value) into the receiver EventMetric. If a metric with the same name exists already, new metric is ignored. AddMetric returns the receiver EventMetrics to allow for the chaining of these calls, for example:

em := metrics.NewEventMetrics(time.Now()).
	AddMetric("sent", &prr.sent).
	AddMetric("rcvd", &prr.rcvd).
	AddMetric("rtt", &prr.rtt)

func (*EventMetrics) Clone

func (em *EventMetrics) Clone() *EventMetrics

Clone clones the underlying fields. This is useful for creating copies of the EventMetrics objects.

func (*EventMetrics) Label

func (em *EventMetrics) Label(name string) string

Label returns an EventMetrics label value by name. Label will return a zero-string ("") for a non-existent label.

func (*EventMetrics) LabelsKeys

func (em *EventMetrics) LabelsKeys() []string

LabelsKeys returns the list of all label keys.

func (*EventMetrics) Metric

func (em *EventMetrics) Metric(name string) Value

Metric returns an EventMetrics metric value by name. Metric will return nil for a non-existent metric.

func (*EventMetrics) MetricsKeys

func (em *EventMetrics) MetricsKeys() []string

MetricsKeys returns the list of all metric keys.

func (*EventMetrics) String

func (em *EventMetrics) String() string

String returns the string representation of the EventMetrics. Note that this is compatible with what vmwatcher understands.

func (*EventMetrics) Update

func (em *EventMetrics) Update(in *EventMetrics) error

Update updates the receiver EventMetrics with the incoming one.

type Float

type Float struct {

	// If Str is defined, this is method used to convert Float into a string.
	Str func(float64) string
	// contains filtered or unexported fields
}

Float implements NumValue with float64 storage. Note that Float is not concurrency safe.

func NewFloat

func NewFloat(f float64) *Float

NewFloat returns a new Float.

func (*Float) Add

func (f *Float) Add(val Value) error

Add adds a Value to the receiver Float. If Value is not Float, an error is returned. It's part of the Value interface.

func (*Float) AddFloat64

func (f *Float) AddFloat64(ff float64)

AddFloat64 adds a float64 to the receiver Float.

func (*Float) AddInt64

func (f *Float) AddInt64(i int64)

AddInt64 adds an int64 to the receiver Float.

func (*Float) Float64

func (f *Float) Float64() float64

Float64 returns the stored float64.

func (*Float) Inc

func (f *Float) Inc()

Inc increments the receiver Float by one. It's part of the NumValue interface.

func (*Float) IncBy

func (f *Float) IncBy(delta NumValue)

IncBy increments the receiver Float by "delta" NumValue. It's part of the NumValue interface.

func (*Float) Int64

func (f *Float) Int64() int64

Int64 returns the stored float64 as int64.

func (*Float) String

func (f *Float) String() string

String returns the string representation of Float. It's part of the Value interface.

type Int

type Int struct {

	// If Str is defined, this is method used to convert Int into a string.
	Str func(int64) string
	// contains filtered or unexported fields
}

Int implements NumValue with int64 storage. Note that Int is not concurrency safe, if you want a concurrency safe integer NumValue, use AtomicInt.

func NewInt

func NewInt(i int64) *Int

NewInt returns a new Int

func (*Int) Add

func (i *Int) Add(val Value) error

Add adds a Value to the receiver Int. If Value is not Int, an error is returned. It's part of the Value interface.

func (*Int) AddFloat64

func (i *Int) AddFloat64(f float64)

AddFloat64 adds a float64 to the receiver Int.

func (*Int) AddInt64

func (i *Int) AddInt64(ii int64)

AddInt64 adds an int64 to the receiver Int.

func (*Int) Float64

func (i *Int) Float64() float64

Float64 returns the stored int64 as a float64

func (*Int) Inc

func (i *Int) Inc()

Inc increments the receiver Int by one. It's part of the NumValue interface.

func (*Int) IncBy

func (i *Int) IncBy(delta NumValue)

IncBy increments the receiver Int by "delta" NumValue. It's part of the NumValue interface.

func (*Int) Int64

func (i *Int) Int64() int64

Int64 returns the stored int64

func (*Int) String

func (i *Int) String() string

String returns the string representation of Int. It's part of the Value interface.

type Kind

type Kind int

Kind represents EventMetrics type. There are currently only two kinds of EventMetrics supported: CUMULATIVE and GAUGE

type Map

type Map struct {
	MapName string // Map key name
	// contains filtered or unexported fields
}

Map implements a key-value store where keys are of type string and values are of type NumValue. It satisfies the Value interface.

func NewMap

func NewMap(mapName string, defaultValue NumValue) *Map

NewMap returns a new Map

func (*Map) Add

func (m *Map) Add(val Value) error

Add adds a value (type Value) to the receiver Map. A non-Map value returns an error. This is part of the Value interface.

func (*Map) AddFloat64

func (m *Map) AddFloat64(f float64)

AddFloat64 generates a panic for the Map type. This is added only to satisfy the Value interface.

func (*Map) AddInt64

func (m *Map) AddInt64(i int64)

AddInt64 generates a panic for the Map type. This is added only to satisfy the Value interface.

func (*Map) GetKey

func (m *Map) GetKey(key string) NumValue

GetKey returns the given key's value. TODO: We should probably add a way to get the list of all the keys in the map.

func (*Map) IncKey

func (m *Map) IncKey(key string)

IncKey increments the given key's value by one.

func (*Map) IncKeyBy

func (m *Map) IncKeyBy(key string, delta NumValue)

IncKeyBy increments the given key's value by NumValue.

func (*Map) Keys

func (m *Map) Keys() []string

Keys returns the list of keys

func (*Map) String

func (m *Map) String() string

String returns the string representation of the receiver Map. This is part of the Value interface.

type NumValue

type NumValue interface {
	Value
	Inc()
	Int64() int64
	Float64() float64
	IncBy(delta NumValue)
}

NumValue represents any numerical metric value, e.g. Int, Float. It's a superset of Value interface.

type String

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

String implements a value type with string storage. It satisfies the Value interface.

func NewString

func NewString(s string) String

NewString returns a new String with the given string value.

func (String) Add

func (s String) Add(val Value) error

Add isn't supported for the String type, this is only to satisfy the Value interface.

func (String) AddFloat64

func (s String) AddFloat64(f float64)

AddFloat64 generates a panic for the String type. This is added only to satisfy the Value interface.

func (String) AddInt64

func (s String) AddInt64(i int64)

AddInt64 generates a panic for the String type. This is added only to satisfy the Value interface.

func (String) String

func (s String) String() string

String simply returns the stored string.

type Value

type Value interface {
	Add(delta Value) error
	AddInt64(i int64)
	AddFloat64(f float64)
	String() string
	// contains filtered or unexported methods
}

Value represents any metric value

Jump to

Keyboard shortcuts

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