move plugin interfaces into separate package
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/plugins"
|
||||
"github.com/influxdata/telegraf/internal"
|
||||
"github.com/influxdata/telegraf/plugins/outputs"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -104,7 +104,7 @@ func (p *PrometheusClient) Collect(ch chan<- prometheus.Metric) {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PrometheusClient) Write(metrics []telegraf.Metric) error {
|
||||
func (p *PrometheusClient) Write(metrics []plugins.Metric) error {
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
@@ -131,9 +131,9 @@ func (p *PrometheusClient) Write(metrics []telegraf.Metric) error {
|
||||
// Get a type if it's available, defaulting to Untyped
|
||||
var mType prometheus.ValueType
|
||||
switch point.Type() {
|
||||
case telegraf.Counter:
|
||||
case plugins.Counter:
|
||||
mType = prometheus.CounterValue
|
||||
case telegraf.Gauge:
|
||||
case plugins.Gauge:
|
||||
mType = prometheus.GaugeValue
|
||||
default:
|
||||
mType = prometheus.UntypedValue
|
||||
@@ -186,7 +186,7 @@ func (p *PrometheusClient) Write(metrics []telegraf.Metric) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
outputs.Add("prometheus_client", func() telegraf.Output {
|
||||
outputs.Add("prometheus_client", func() plugins.Output {
|
||||
return &PrometheusClient{
|
||||
ExpirationInterval: internal.Duration{Duration: time.Second * 60},
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/plugins"
|
||||
"github.com/influxdata/telegraf/internal"
|
||||
"github.com/influxdata/telegraf/metric"
|
||||
"github.com/influxdata/telegraf/plugins/inputs/prometheus"
|
||||
@@ -37,7 +37,7 @@ func TestPrometheusWritePointEmptyTag(t *testing.T) {
|
||||
tags,
|
||||
map[string]interface{}{"value": 1.0},
|
||||
now)
|
||||
var metrics = []telegraf.Metric{
|
||||
var metrics = []plugins.Metric{
|
||||
pt1,
|
||||
pt2,
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func TestPrometheusWritePointEmptyTag(t *testing.T) {
|
||||
tags,
|
||||
map[string]interface{}{"value": 1.0},
|
||||
now)
|
||||
metrics = []telegraf.Metric{
|
||||
metrics = []plugins.Metric{
|
||||
pt3,
|
||||
pt4,
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func TestPrometheusExpireOldMetrics(t *testing.T) {
|
||||
tags,
|
||||
map[string]interface{}{"value": 0.0},
|
||||
now)
|
||||
var metrics = []telegraf.Metric{pt1}
|
||||
var metrics = []plugins.Metric{pt1}
|
||||
require.NoError(t, pClient.Write(metrics))
|
||||
|
||||
for _, m := range pClient.metrics {
|
||||
@@ -122,7 +122,7 @@ func TestPrometheusExpireOldMetrics(t *testing.T) {
|
||||
tags,
|
||||
map[string]interface{}{"value": 1.0},
|
||||
now)
|
||||
var metrics2 = []telegraf.Metric{pt2}
|
||||
var metrics2 = []plugins.Metric{pt2}
|
||||
require.NoError(t, pClient.Write(metrics2))
|
||||
|
||||
expected := []struct {
|
||||
|
||||
Reference in New Issue
Block a user