From 1d4fa5f57da108453d7a39d9f1eef170ef64ee86 Mon Sep 17 00:00:00 2001 From: Sven Rebhan Date: Tue, 3 Sep 2024 14:25:10 +0200 Subject: [PATCH] Adapt to new API --- plugins/parsers/prometheusremotewrite/parser.go | 9 +-------- plugins/parsers/prometheusremotewrite/parser_test.go | 5 ++--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/plugins/parsers/prometheusremotewrite/parser.go b/plugins/parsers/prometheusremotewrite/parser.go index 72695f471d9b5..3480d3c61b1a6 100644 --- a/plugins/parsers/prometheusremotewrite/parser.go +++ b/plugins/parsers/prometheusremotewrite/parser.go @@ -7,9 +7,7 @@ import ( "time" "github.com/prometheus/common/model" - "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/prompb" - "github.com/prometheus/prometheus/storage/remote" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/metric" @@ -63,12 +61,7 @@ func (p *Parser) Parse(buf []byte) ([]telegraf.Metric, error) { } for _, hp := range ts.Histograms { - var h *histogram.FloatHistogram - if hp.IsFloatHistogram() { - h = remote.FloatHistogramProtoToFloatHistogram(hp) - } else { - h = remote.HistogramProtoToFloatHistogram(hp) - } + h := hp.ToFloatHistogram() if hp.Timestamp > 0 { t = time.Unix(0, hp.Timestamp*1000000) diff --git a/plugins/parsers/prometheusremotewrite/parser_test.go b/plugins/parsers/prometheusremotewrite/parser_test.go index a7cddb477adcd..f98c4ca516e58 100644 --- a/plugins/parsers/prometheusremotewrite/parser_test.go +++ b/plugins/parsers/prometheusremotewrite/parser_test.go @@ -6,7 +6,6 @@ import ( "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/prompb" - "github.com/prometheus/prometheus/storage/remote" "github.com/stretchr/testify/require" "github.com/influxdata/telegraf" @@ -122,7 +121,7 @@ func TestHistograms(t *testing.T) { {Name: "__name__", Value: "test_metric_seconds"}, }, Histograms: []prompb.Histogram{ - remote.HistogramToHistogramProto(0, generateTestHistogram(1)), + prompb.FromIntHistogram(0, generateTestHistogram(1)), }, }, { @@ -130,7 +129,7 @@ func TestHistograms(t *testing.T) { {Name: "__name__", Value: "test_float_metric_seconds"}, }, Histograms: []prompb.Histogram{ - remote.FloatHistogramToHistogramProto(0, generateTestFloatHistogram(2)), + prompb.FromFloatHistogram(0, generateTestFloatHistogram(2)), }, }, },