types

package
v0.0.0-...-2b0a6a7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const StatsdSourceID = "s"

StatsdSourceID stores the key used to tag metrics with the origin IP address. Should be short to avoid extra hashing and memory overhead for map operations.

Variables

This section is empty.

Functions

func NormalizeTagKey

func NormalizeTagKey(key string) string

NormalizeTagKey cleans up the key of a tag.

Types

type AggregatedMetrics

type AggregatedMetrics interface {
	MetricsName() string
	Delete(string)
	DeleteChild(string, string)
	HasChildren(string) bool
}

AggregatedMetrics is an interface for aggregated metrics.

type AlertType

type AlertType byte

AlertType is the type of alert.

const (
	// AlertInfo is alert level "info".
	AlertInfo AlertType = iota // Must be zero to work as default
	// AlertWarning is alert level "warning".
	AlertWarning
	// AlertError is alert level "error".
	AlertError
	// AlertSuccess is alert level "success".
	AlertSuccess
)

func (AlertType) String

func (a AlertType) String() string

func (AlertType) StringWithEmptyDefault

func (a AlertType) StringWithEmptyDefault() string

StringWithEmptyDefault returns empty string for default alert type.

type Counter

type Counter struct {
	PerSecond float64  // The calculated per second rate
	Value     int64    // The numeric value of the metric
	Timestamp Nanotime // Last time value was updated
	Hostname  string   // Hostname of the source of the metric
	Tags      Tags     // The tags for the counter
}

Counter is used for storing aggregated values for counters.

func NewCounter

func NewCounter(timestamp Nanotime, value int64, hostname string, tags Tags) Counter

NewCounter initialises a new counter.

type Counters

type Counters map[string]map[string]Counter

Counters stores a map of counters by tags.

func (Counters) Delete

func (c Counters) Delete(k string)

Delete deletes the metrics from the collection.

func (Counters) DeleteChild

func (c Counters) DeleteChild(k, t string)

DeleteChild deletes the metrics from the collection for the given tags.

func (Counters) Each

func (c Counters) Each(f func(string, string, Counter))

Each iterates over each counter.

func (Counters) HasChildren

func (c Counters) HasChildren(k string) bool

HasChildren returns whether there are more children nested under the key.

func (Counters) MetricsName

func (c Counters) MetricsName() string

MetricsName returns the name of the aggregated metrics collection.

type Event

type Event struct {
	// Title of the event.
	Title string
	// Text of the event. Supports line breaks.
	Text string
	// DateHappened of the event. Unix epoch timestamp. Default is now when not specified in incoming metric.
	DateHappened int64
	// Hostname of the event. This field contains information that is received in the body of the event (optional).
	Hostname string
	// AggregationKey of the event, to group it with some other events.
	AggregationKey string
	// SourceTypeName of the event.
	SourceTypeName string
	// Tags of the event.
	Tags Tags
	// IP of the source of the metric
	SourceIP IP
	// Priority of the event.
	Priority Priority
	// AlertType of the event.
	AlertType AlertType
}

Event represents an event, described at http://docs.datadoghq.com/guides/dogstatsd/

type Events

type Events []Event

Events represents a list of events.

type Gauge

type Gauge struct {
	Value     float64  // The numeric value of the metric
	Timestamp Nanotime // Last time value was updated
	Hostname  string   // Hostname of the source of the metric
	Tags      Tags     // The tags for the gauge
}

Gauge is used for storing aggregated values for gauges.

func NewGauge

func NewGauge(timestamp Nanotime, value float64, hostname string, tags Tags) Gauge

NewGauge initialises a new gauge.

type Gauges

type Gauges map[string]map[string]Gauge

Gauges stores a map of gauges by tags.

func (Gauges) Delete

func (g Gauges) Delete(k string)

Delete deletes the metrics from the collection.

func (Gauges) DeleteChild

func (g Gauges) DeleteChild(k, t string)

DeleteChild deletes the metrics from the collection for the given tags.

func (Gauges) Each

func (g Gauges) Each(f func(string, string, Gauge))

Each iterates over each gauge.

func (Gauges) HasChildren

func (g Gauges) HasChildren(k string) bool

HasChildren returns whether there are more children nested under the key.

func (Gauges) MetricsName

func (g Gauges) MetricsName() string

MetricsName returns the name of the aggregated metrics collection.

type IP

type IP string

IP is a v4/v6 IP address. We do not use net.IP because it will involve conversion to string and back several times.

const UnknownIP IP = ""

UnknownIP is an IP of an unknown source.

type Metric

type Metric struct {
	Name        string     // The name of the metric
	Value       float64    // The numeric value of the metric
	Tags        Tags       // The tags for the metric
	StringValue string     // The string value for some metrics e.g. Set
	Hostname    string     // Hostname of the source of the metric
	SourceIP    IP         // IP of the source of the metric
	Type        MetricType // The type of metric
}

Metric represents a single data collected datapoint.

func NewMetric

func NewMetric(name string, value float64, mtype MetricType, tags Tags) *Metric

NewMetric creates a metric with tags.

func (*Metric) String

func (m *Metric) String() string

type MetricMap

type MetricMap struct {
	MetricStats
	FlushInterval time.Duration
	Counters      Counters
	Timers        Timers
	Gauges        Gauges
	Sets          Sets
}

MetricMap is used for storing aggregated Metric values. The keys of each map are metric names.

func (*MetricMap) String

func (m *MetricMap) String() string

type MetricStats

type MetricStats struct {
	ProcessingTime time.Duration
	NumStats       uint32
}

MetricStats holds stats of an Aggregator.

type MetricType

type MetricType byte

MetricType is an enumeration of all the possible types of Metric.

const (

	// COUNTER is statsd counter type
	COUNTER MetricType = iota
	// TIMER is statsd timer type
	TIMER
	// GAUGE is statsd gauge type
	GAUGE
	// SET is statsd set type
	SET
)

func (MetricType) String

func (m MetricType) String() string

type Nanotime

type Nanotime int64

Nanotime is the number of nanoseconds elapsed since January 1, 1970 UTC. Get the value with time.Now().UnixNano().

type Percentile

type Percentile struct {
	Float float64
	Str   string
}

Percentile is used to store the aggregation for a percentile.

func (*Percentile) String

func (p *Percentile) String() string

String returns the string value of a percentile.

type Percentiles

type Percentiles []Percentile

Percentiles represents an array of percentiles.

func (*Percentiles) Set

func (p *Percentiles) Set(s string, f float64)

Set append a percentile aggregation to the percentiles.

func (*Percentiles) String

func (p *Percentiles) String() string

String returns the string value of percentiles.

type Priority

type Priority byte

Priority of an event.

const (
	// PriNormal is normal priority.
	PriNormal Priority = iota // Must be zero to work as default
	// PriLow is low priority.
	PriLow
)

func (Priority) String

func (p Priority) String() string

func (Priority) StringWithEmptyDefault

func (p Priority) StringWithEmptyDefault() string

StringWithEmptyDefault returns empty string for default priority.

type Set

type Set struct {
	Values    map[string]struct{}
	Timestamp Nanotime // Last time value was updated
	Hostname  string   // Hostname of the source of the metric
	Tags      Tags     // The tags for the set
}

Set is used for storing aggregated values for sets.

func NewSet

func NewSet(timestamp Nanotime, values map[string]struct{}, hostname string, tags Tags) Set

NewSet initialises a new set.

type Sets

type Sets map[string]map[string]Set

Sets stores a map of sets by tags.

func (Sets) Delete

func (s Sets) Delete(k string)

Delete deletes the metrics from the collection.

func (Sets) DeleteChild

func (s Sets) DeleteChild(k, t string)

DeleteChild deletes the metrics from the collection for the given tags.

func (Sets) Each

func (s Sets) Each(f func(string, string, Set))

Each iterates over each set.

func (Sets) HasChildren

func (s Sets) HasChildren(k string) bool

HasChildren returns whether there are more children nested under the key.

func (Sets) MetricsName

func (s Sets) MetricsName() string

MetricsName returns the name of the aggregated metrics collection.

type Tags

type Tags []string

Tags represents a list of tags. Tags can be of two forms: 1. "key:value". "value" may contain column(s) as well. 2. "tag". No column. Each tag's key and/or value may contain characters invalid for a particular backend. Backends are expected to handle them appropriately. Different backends may have different sets of valid characters so it is undesirable to have restrictions on the input side.

func (Tags) SortedString

func (tags Tags) SortedString() string

SortedString sorts the tags alphabetically and returns a comma-separated string representation of the tags. Note that this method may mutate the original object.

func (Tags) String

func (tags Tags) String() string

String returns a comma-separated string representation of the tags.

type Timer

type Timer struct {
	Count       int         // The number of timers in the series
	PerSecond   float64     // The calculated per second rate
	Mean        float64     // The mean time of the series
	Median      float64     // The median time of the series
	Min         float64     // The minimum time of the series
	Max         float64     // The maximum time of the series
	StdDev      float64     // The standard deviation for the series
	Sum         float64     // The sum for the series
	SumSquares  float64     // The sum squares for the series
	Values      []float64   // The numeric value of the metric
	Percentiles Percentiles // The percentile aggregations of the metric
	Timestamp   Nanotime    // Last time value was updated
	Hostname    string      // Hostname of the source of the metric
	Tags        Tags        // The tags for the timer
}

Timer is used for storing aggregated values for timers.

func NewTimer

func NewTimer(timestamp Nanotime, values []float64, hostname string, tags Tags) Timer

NewTimer initialises a new timer.

type Timers

type Timers map[string]map[string]Timer

Timers stores a map of timers by tags.

func (Timers) Delete

func (t Timers) Delete(k string)

Delete deletes the metrics from the collection.

func (Timers) DeleteChild

func (t Timers) DeleteChild(k, tags string)

DeleteChild deletes the metrics from the collection for the given tags.

func (Timers) Each

func (t Timers) Each(f func(string, string, Timer))

Each iterates over each timer.

func (Timers) HasChildren

func (t Timers) HasChildren(k string) bool

HasChildren returns whether there are more children nested under the key.

func (Timers) MetricsName

func (t Timers) MetricsName() string

MetricsName returns the name of the aggregated metrics collection.

Jump to

Keyboard shortcuts

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