stats

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2017 License: AGPL-3.0 Imports: 10 Imported by: 0

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)
	Data                      // Values are data amounts (bytes)
)

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

func D added in v0.8.2

func D(d time.Duration) float64

D formats a duration for emission. The reverse of D() is ToD().

func ToD added in v0.8.2

func ToD(d float64) time.Duration

ToD converts an emitted duration to a time.Duration. The reverse of ToD() is D().

Types

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 DummySink added in v0.5.0

type DummySink map[string]float64

func (DummySink) Add added in v0.5.0

func (d DummySink) Add(s Sample)

func (DummySink) Format added in v0.5.0

func (d DummySink) Format() map[string]float64

type GaugeSink

type GaugeSink struct {
	Value float64
}

func (*GaugeSink) Add

func (g *GaugeSink) Add(s Sample)

func (*GaugeSink) Format

func (g *GaugeSink) Format() map[string]float64

type Metric

type Metric struct {
	Name       string      `json:"name"`
	Type       MetricType  `json:"type"`
	Contains   ValueType   `json:"contains"`
	Tainted    null.Bool   `json:"tainted"`
	Thresholds Thresholds  `json:"thresholds"`
	Submetrics []Submetric `json:"submetrics"`
	Sink       Sink        `json:"-"`
}

A Metric defines the shape of a set of data.

func New

func New(name string, typ MetricType, t ...ValueType) *Metric

func (Metric) HumanizeValue

func (m Metric) HumanizeValue(v float64) string

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 RateSink

type RateSink struct {
	Trues int64
	Total int64
}

func (*RateSink) Add

func (r *RateSink) Add(s Sample)

func (RateSink) Format

func (r RateSink) Format() map[string]float64

type Sample

type Sample struct {
	Metric *Metric
	Time   time.Time
	Tags   map[string]string
	Value  float64
}

A Sample is a single measurement.

type Sink

type Sink interface {
	Add(s Sample)
	Format() map[string]float64
}

type Submetric added in v0.13.0

type Submetric struct {
	Name   string            `json:"name"`
	Tags   map[string]string `json:"tags"`
	Metric *Metric           `json:"metric"`
}

A Submetric represents a filtered dataset based on a parent metric.

func NewSubmetric added in v0.13.0

func NewSubmetric(name string) (parentName string, sm Submetric)

Creates a submetric from a name.

type Threshold added in v0.13.0

type Threshold struct {
	Source string
	Failed bool
	// contains filtered or unexported fields
}

func NewThreshold added in v0.13.0

func NewThreshold(src string, rt *goja.Runtime) (*Threshold, error)

func (*Threshold) Run added in v0.13.0

func (t *Threshold) Run() (bool, error)

func (Threshold) RunNoTaint added in v0.13.0

func (t Threshold) RunNoTaint() (bool, error)

type Thresholds added in v0.13.0

type Thresholds struct {
	Runtime    *goja.Runtime
	Thresholds []*Threshold
}

func NewThresholds added in v0.13.0

func NewThresholds(sources []string) (Thresholds, error)

func (Thresholds) MarshalJSON added in v0.13.0

func (ts Thresholds) MarshalJSON() ([]byte, error)

func (*Thresholds) Run added in v0.13.0

func (ts *Thresholds) Run(sink Sink) (bool, error)

func (*Thresholds) RunAll added in v0.13.0

func (ts *Thresholds) RunAll() (bool, error)

func (*Thresholds) UnmarshalJSON added in v0.13.0

func (ts *Thresholds) UnmarshalJSON(data []byte) error

func (*Thresholds) UpdateVM added in v0.13.0

func (ts *Thresholds) UpdateVM(sink Sink) error

type TrendSink

type TrendSink struct {
	Values []float64
	// contains filtered or unexported fields
}

func (*TrendSink) Add

func (t *TrendSink) Add(s Sample)

func (*TrendSink) Format

func (t *TrendSink) Format() map[string]float64

func (*TrendSink) P

func (t *TrendSink) P(pct float64) float64

type ValueType

type ValueType int

The type of values a metric contains.

func (ValueType) MarshalJSON

func (t ValueType) MarshalJSON() ([]byte, error)

MarshalJSON serializes a ValueType as a human readable string.

func (ValueType) String

func (t ValueType) String() string

func (*ValueType) UnmarshalJSON

func (t *ValueType) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes a ValueType from a string representation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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