Support Processor & Aggregator Plugins

closes #1726
This commit is contained in:
Cameron Sparr
2016-09-08 15:22:10 +01:00
parent 974221f0cf
commit 64a71263a1
28 changed files with 1832 additions and 654 deletions

View File

@@ -4,6 +4,7 @@ import (
"time"
"github.com/influxdata/influxdb/client/v2"
"github.com/influxdata/influxdb/models"
)
// ValueType is an enumeration of metric types that represent a simple value.
@@ -33,6 +34,9 @@ type Metric interface {
// UnixNano returns the unix nano time of the metric
UnixNano() int64
// HashID returns a non-cryptographic hash of the metric (name + tags)
HashID() uint64
// Fields returns the fields for the metric
Fields() map[string]interface{}
@@ -44,13 +48,21 @@ type Metric interface {
// Point returns a influxdb client.Point object
Point() *client.Point
// SetAggregate sets the metric's aggregate status
// This is so that aggregate metrics don't get re-sent to aggregator plugins
SetAggregate(bool)
// IsAggregate returns true if the metric is an aggregate
IsAggregate() bool
}
// metric is a wrapper of the influxdb client.Point struct
type metric struct {
pt *client.Point
pt models.Point
mType ValueType
isaggregate bool
}
// NewMetric returns an untyped metric.
@@ -60,7 +72,7 @@ func NewMetric(
fields map[string]interface{},
t time.Time,
) (Metric, error) {
pt, err := client.NewPoint(name, tags, fields, t)
pt, err := models.NewPoint(name, tags, fields, t)
if err != nil {
return nil, err
}
@@ -79,7 +91,7 @@ func NewGaugeMetric(
fields map[string]interface{},
t time.Time,
) (Metric, error) {
pt, err := client.NewPoint(name, tags, fields, t)
pt, err := models.NewPoint(name, tags, fields, t)
if err != nil {
return nil, err
}
@@ -98,7 +110,7 @@ func NewCounterMetric(
fields map[string]interface{},
t time.Time,
) (Metric, error) {
pt, err := client.NewPoint(name, tags, fields, t)
pt, err := models.NewPoint(name, tags, fields, t)
if err != nil {
return nil, err
}
@@ -124,6 +136,10 @@ func (m *metric) Type() ValueType {
return m.mType
}
func (m *metric) HashID() uint64 {
return m.pt.HashID()
}
func (m *metric) UnixNano() int64 {
return m.pt.UnixNano()
}
@@ -141,5 +157,13 @@ func (m *metric) PrecisionString(precison string) string {
}
func (m *metric) Point() *client.Point {
return m.pt
return client.NewPointFrom(m.pt)
}
func (m *metric) IsAggregate() bool {
return m.isaggregate
}
func (m *metric) SetAggregate(b bool) {
m.isaggregate = b
}