2015-05-22 23:45:14 +00:00
|
|
|
package telegraf
|
2015-04-06 16:32:10 +00:00
|
|
|
|
2018-11-05 21:34:28 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
2015-04-06 16:32:10 +00:00
|
|
|
|
2018-11-05 21:34:28 +00:00
|
|
|
// Accumulator allows adding metrics to the processing flow.
|
2015-10-16 22:13:32 +00:00
|
|
|
type Accumulator interface {
|
2016-09-05 09:41:35 +00:00
|
|
|
// AddFields adds a metric to the accumulator with the given measurement
|
|
|
|
// name, fields, and tags (and timestamp). If a timestamp is not provided,
|
|
|
|
// then the accumulator sets it to "now".
|
2016-01-27 21:21:36 +00:00
|
|
|
AddFields(measurement string,
|
|
|
|
fields map[string]interface{},
|
|
|
|
tags map[string]string,
|
|
|
|
t ...time.Time)
|
2015-05-20 05:19:32 +00:00
|
|
|
|
2016-09-05 09:41:35 +00:00
|
|
|
// AddGauge is the same as AddFields, but will add the metric as a "Gauge" type
|
2016-08-31 16:27:37 +00:00
|
|
|
AddGauge(measurement string,
|
|
|
|
fields map[string]interface{},
|
|
|
|
tags map[string]string,
|
|
|
|
t ...time.Time)
|
|
|
|
|
2016-09-05 09:41:35 +00:00
|
|
|
// AddCounter is the same as AddFields, but will add the metric as a "Counter" type
|
2016-08-31 16:27:37 +00:00
|
|
|
AddCounter(measurement string,
|
|
|
|
fields map[string]interface{},
|
|
|
|
tags map[string]string,
|
|
|
|
t ...time.Time)
|
|
|
|
|
2017-10-24 23:28:52 +00:00
|
|
|
// AddSummary is the same as AddFields, but will add the metric as a "Summary" type
|
|
|
|
AddSummary(measurement string,
|
|
|
|
fields map[string]interface{},
|
|
|
|
tags map[string]string,
|
|
|
|
t ...time.Time)
|
|
|
|
|
|
|
|
// AddHistogram is the same as AddFields, but will add the metric as a "Histogram" type
|
|
|
|
AddHistogram(measurement string,
|
|
|
|
fields map[string]interface{},
|
|
|
|
tags map[string]string,
|
|
|
|
t ...time.Time)
|
|
|
|
|
2018-11-05 21:34:28 +00:00
|
|
|
// AddMetric adds an metric to the accumulator.
|
|
|
|
AddMetric(Metric)
|
|
|
|
|
|
|
|
// SetPrecision takes two time.Duration objects. If the first is non-zero,
|
|
|
|
// it sets that as the precision. Otherwise, it takes the second argument
|
|
|
|
// as the order of time that the metrics should be rounded to, with the
|
|
|
|
// maximum being 1s.
|
2016-06-13 14:21:11 +00:00
|
|
|
SetPrecision(precision, interval time.Duration)
|
|
|
|
|
2018-11-05 21:34:28 +00:00
|
|
|
// Report an error.
|
2016-09-08 14:22:10 +00:00
|
|
|
AddError(err error)
|
2018-11-05 21:34:28 +00:00
|
|
|
|
|
|
|
// Upgrade to a TrackingAccumulator with space for maxTracked
|
|
|
|
// metrics/batches.
|
|
|
|
WithTracking(maxTracked int) TrackingAccumulator
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrackingID uniquely identifies a tracked metric group
|
|
|
|
type TrackingID uint64
|
|
|
|
|
|
|
|
// DeliveryInfo provides the results of a delivered metric group.
|
|
|
|
type DeliveryInfo interface {
|
|
|
|
// ID is the TrackingID
|
|
|
|
ID() TrackingID
|
|
|
|
|
|
|
|
// Delivered returns true if the metric was processed successfully.
|
|
|
|
Delivered() bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrackingAccumulator is an Accumulator that provides a signal when the
|
|
|
|
// metric has been fully processed. Sending more metrics than the accumulator
|
|
|
|
// has been allocated for without reading status from the Accepted or Rejected
|
|
|
|
// channels is an error.
|
|
|
|
type TrackingAccumulator interface {
|
|
|
|
Accumulator
|
|
|
|
|
|
|
|
// Add the Metric and arrange for tracking feedback after processing..
|
|
|
|
AddTrackingMetric(m Metric) TrackingID
|
|
|
|
|
|
|
|
// Add a group of Metrics and arrange for a signal when the group has been
|
|
|
|
// processed.
|
|
|
|
AddTrackingMetricGroup(group []Metric) TrackingID
|
|
|
|
|
|
|
|
// Delivered returns a channel that will contain the tracking results.
|
|
|
|
Delivered() <-chan DeliveryInfo
|
2015-04-06 16:32:10 +00:00
|
|
|
}
|