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
- type AtomicInt
- type EventMetrics
- func (em *EventMetrics) AddLabel(name string, val string) *EventMetrics
- func (em *EventMetrics) AddMetric(name string, val Value) *EventMetrics
- func (em *EventMetrics) Clone() *EventMetrics
- func (em *EventMetrics) Label(name string) string
- func (em *EventMetrics) LabelsKeys() []string
- func (em *EventMetrics) Metric(name string) Value
- func (em *EventMetrics) MetricsKeys() []string
- func (em *EventMetrics) String() string
- func (em *EventMetrics) Update(in *EventMetrics) error
- type Float
- type Int
- type Kind
- type Map
- type NumValue
- type String
- type Value
Constants ¶
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 (*AtomicInt) Add ¶
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 ¶
AddFloat64 adds a float64 to the receiver Int.
func (*AtomicInt) Inc ¶
func (i *AtomicInt) Inc()
Inc increments the receiver AtomicInt by one. It's part of the NumValue 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 (*Float) Add ¶
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 ¶
AddFloat64 adds a float64 to the receiver Float.
func (*Float) Inc ¶
func (f *Float) Inc()
Inc increments the receiver Float by one. It's part of the NumValue 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 (*Int) Add ¶
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 ¶
AddFloat64 adds a float64 to the receiver Int.
func (*Int) Inc ¶
func (i *Int) Inc()
Inc increments the receiver Int by one. It's part of the NumValue 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 (*Map) Add ¶
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 ¶
AddFloat64 generates a panic for the Map type. This is added only to satisfy the Value interface.
func (*Map) AddInt64 ¶
AddInt64 generates a panic for the Map type. This is added only to satisfy the Value interface.
func (*Map) GetKey ¶
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.
type 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 (String) Add ¶
Add isn't supported for the String type, this is only to satisfy the Value interface.
func (String) AddFloat64 ¶
AddFloat64 generates a panic for the String type. This is added only to satisfy the Value interface.