Documentation ¶
Index ¶
- Constants
- func NormalizeTagKey(key string) string
- type AggregatedMetrics
- type AlertType
- type Backend
- type BackendFactory
- type CloudProvider
- type CloudProviderFactory
- type Counter
- type Counters
- type Event
- type Events
- type Gauge
- type Gauges
- type IP
- type Instance
- type Metric
- type MetricMap
- type MetricType
- type Nanotime
- type Percentile
- type Percentiles
- type Priority
- type RunnableBackend
- type SendCallback
- type Set
- type Sets
- type Tags
- type Timer
- type TimerSubtypes
- type Timers
- type Wait
Constants ¶
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 ¶
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.
func (AlertType) StringWithEmptyDefault ¶
StringWithEmptyDefault returns empty string for default alert type.
type Backend ¶
type Backend interface { // Name returns the name of the backend. Name() string // SendMetricsAsync flushes the metrics to the backend, preparing payload synchronously but doing the send asynchronously. // Must not read/write MetricMap asynchronously. SendMetricsAsync(context.Context, *MetricMap, SendCallback) // SendEvent sends event to the backend. SendEvent(context.Context, *Event) error }
Backend represents a backend.
type BackendFactory ¶
BackendFactory is a function that returns a Backend.
type CloudProvider ¶
type CloudProvider interface { // Name returns the name of the cloud provider. Name() string // Instance returns instances details from the cloud provider. // ip -> nil pointer if instance was not found. // map is returned even in case of errors because it may contain partial data. Instance(context.Context, ...IP) (map[IP]*Instance, error) // MaxInstancesBatch returns maximum number of instances that could be requested via the Instance method. MaxInstancesBatch() int // SelfIP returns host's IPv4 address. SelfIP() (IP, error) // EstimatedTags returns a guess of how many tags are likely to be added by the CloudProvider EstimatedTags() int }
CloudProvider represents a cloud provider.
type CloudProviderFactory ¶
type CloudProviderFactory func(v *viper.Viper, logger logrus.FieldLogger) (CloudProvider, error)
CloudProviderFactory is a function that returns a CloudProvider.
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.
type Counters ¶
Counters stores a map of counters by tags.
func (Counters) DeleteChild ¶
DeleteChild deletes the metrics from the collection for the given tags.
func (Counters) HasChildren ¶
HasChildren returns whether there are more children nested under the key.
func (Counters) MetricsName ¶
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 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.
type Gauges ¶
Gauges stores a map of gauges by tags.
func (Gauges) DeleteChild ¶
DeleteChild deletes the metrics from the collection for the given tags.
func (Gauges) HasChildren ¶
HasChildren returns whether there are more children nested under the key.
func (Gauges) MetricsName ¶
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 Rate float64 // The sampling rate of the metric Tags Tags // The tags for the metric TagsKey string // The tags rendered as a string to uniquely identify the tagset in a map 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 DoneFunc func() // Returns the metric to the pool. May be nil. Call Metric.Done(), not this. }
Metric represents a single data collected datapoint.
func (*Metric) Bucket ¶
Bucket will pick a distribution bucket for this metric to land in. max is exclusive.
func (*Metric) Done ¶
func (m *Metric) Done()
Done invokes DoneFunc if it's set, returning the metric to the pool.
type MetricMap ¶
MetricMap is used for storing aggregated Metric values. The keys of each map are metric names.
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 ¶
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.
func (Priority) StringWithEmptyDefault ¶
StringWithEmptyDefault returns empty string for default priority.
type RunnableBackend ¶
type RunnableBackend interface { Backend // Run executes backend send operations. Should be started in a goroutine. Run(context.Context) }
RunnableBackend represents a backend that needs a Run method to be executed to work.
type SendCallback ¶
type SendCallback func([]error)
SendCallback is called by Backend.SendMetricsAsync() to notify about the result of operation. A list of errors is passed to the callback. It may be empty or contain nil values. Every non-nil value is an error that happened while sending metrics.
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.
type Sets ¶
Sets stores a map of sets by tags.
func (Sets) DeleteChild ¶
DeleteChild deletes the metrics from the collection for the given tags.
func (Sets) HasChildren ¶
HasChildren returns whether there are more children nested under the key.
func (Sets) MetricsName ¶
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 ¶
SortedString sorts the tags alphabetically and returns a comma-separated string representation of the tags. Note that this method may mutate the original object.
type Timer ¶
type Timer struct { Count int // The number of timers in the series SampledCount float64 // Number of timings received, divided by sampling rate 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 NewTimerValues ¶
NewTimerValues initialises a new timer only from Values array
type TimerSubtypes ¶
type TimerSubtypes struct { Lower bool LowerPct bool // pct Upper bool UpperPct bool // pct Count bool CountPct bool // pct CountPerSecond bool Mean bool MeanPct bool // pct Median bool StdDev bool Sum bool SumPct bool // pct SumSquares bool SumSquaresPct bool // pct }
func DisabledSubMetrics ¶
func DisabledSubMetrics(viper *viper.Viper) TimerSubtypes
type Timers ¶
Timers stores a map of timers by tags.
func (Timers) DeleteChild ¶
DeleteChild deletes the metrics from the collection for the given tags.
func (Timers) HasChildren ¶
HasChildren returns whether there are more children nested under the key.
func (Timers) MetricsName ¶
MetricsName returns the name of the aggregated metrics collection.