Documentation
¶
Index ¶
Constants ¶
View Source
const ( Counter = MetricType(iota) // A counter that sums its data points Gauge // A gauge that displays the latest value Trend // A trend, min/max/avg/med are interesting Rate // A rate, displays % of values that aren't 0 )
Possible values for MetricType.
View Source
const ( Default = ValueType(iota) // Values are presented as-is Time // Values are timestamps (nanoseconds) )
Possible values for ValueType.
Variables ¶
View Source
var ErrInvalidMetricType = errors.New("Invalid metric type")
The serialized metric type is invalid.
View Source
var ErrInvalidValueType = errors.New("Invalid value type")
The serialized value type is invalid.
Functions ¶
Types ¶
type Collector ¶
type Collector interface {
// Run is called in a goroutine and starts the collector. Should commit samples to the backend
// at regular intervals and when the context is terminated.
Run(ctx context.Context)
// Collect receives a set of samples. This method is never called concurrently, and only while
// the context for Run() is valid, but should defer as much work as possible to Run().
Collect(samples []Sample)
}
A Collector abstracts away the details of a storage backend from the application.
type CounterSink ¶
type CounterSink struct {
Value float64
}
func (*CounterSink) Add ¶
func (c *CounterSink) Add(s Sample)
func (*CounterSink) Format ¶
func (c *CounterSink) Format() map[string]float64
type Metric ¶
type Metric struct {
Name string `json:"-"`
Type MetricType `json:"type"`
Contains ValueType `json:"contains"`
// Filled in by the API when requested, the server side cannot count on its presence.
Sample map[string]float64 `json:"sample"`
}
A Metric defines the shape of a set of data.
func (Metric) HumanizeValue ¶
type MetricType ¶
type MetricType int
A MetricType specifies the type of a metric.
func (MetricType) MarshalJSON ¶
func (t MetricType) MarshalJSON() ([]byte, error)
MarshalJSON serializes a MetricType as a human readable string.
func (MetricType) String ¶
func (t MetricType) String() string
func (*MetricType) UnmarshalJSON ¶
func (t *MetricType) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes a MetricType from a string representation.
type TrendSink ¶
type TrendSink struct {
Values []float64
// contains filtered or unexported fields
}
type ValueType ¶
type ValueType int
The type of values a metric contains.
func (ValueType) MarshalJSON ¶
MarshalJSON serializes a ValueType as a human readable string.
func (*ValueType) UnmarshalJSON ¶
UnmarshalJSON deserializes a ValueType from a string representation.
Click to show internal directories.
Click to hide internal directories.