Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var VERSION = "0.0.1"
VERSION is link time populated based on the current git tag.
Functions ¶
This section is empty.
Types ¶
type Measurement ¶
type Measurement struct {
// Name is the metric to contribute to.
Name string
// Timestamp at which the measurement was taken.
Timestamp time.Time
// Type of the metric we wish to amend.
Type MetricType
// Value is the amount by which we will amend the metric.
// For Gauges, the amendment might be "replace".
Value float64
// SampleRate that this measurement was taken at.
// For most applications, this should be set to 1.0
SampleRate float32
// Modifier allows gauges to be treated differently
//
// A value of "-" subtracts Value from the metric's previous value.
// A value of "+" adds Value to metric's previous value. An empty
// value replaces the metric's value with Value.
Modifier string
}
Measurement is a point in time value that is used to amend a metric.
type MetricSet ¶
type MetricSet struct {
Counters map[string]float64 `json:"counters,omitempty"`
Gauges map[string]float64 `json:"gauges,omitempty"`
// contains filtered or unexported fields
}
MetricSet provides a container for a set of metrics, and encodes the rules for how metrics are updated given a Measurement.
func NewMetricSet ¶
NewMetricSet constructs a MetricSet which can be used to turn Measurements into metrics, that can be reported via a reporter.
If a parent is given, it is expected to be the previously reported MetricSet, in order to capture the change in metrics, for both DerivedCounters, and modified Guages.
func (*MetricSet) Snapshot ¶
Snapshot returns a copy of the MetricSet, removing the reference to the MetricSet's parent.
func (*MetricSet) Update ¶
func (ms *MetricSet) Update(m *Measurement)
Update applies a Measurement to the MetricSet depending on its Type.
In cases where a Measurement for a Metric has a different Type than was previously updated, a new Metric with that type will be created.
type MetricType ¶
type MetricType int
MetricType represents the type of metric, Measurements will result in.
const ( // Counter represents a positive change in value for a flush interval. Counter MetricType = iota // DerivedCounter represents a monotonically increasing counter value that // is not supposed to be reset by the source. DerivedCounter // Gauge represents the value right now. Gauge // Timer is currently unused, but exists for statsd parsing purposes. Timer )
