Skip to content

Commit

Permalink
Adapt to new API
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan committed Sep 3, 2024
1 parent 1949d19 commit 1d4fa5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
9 changes: 1 addition & 8 deletions plugins/parsers/prometheusremotewrite/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions plugins/parsers/prometheusremotewrite/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -122,15 +121,15 @@ func TestHistograms(t *testing.T) {
{Name: "__name__", Value: "test_metric_seconds"},
},
Histograms: []prompb.Histogram{
remote.HistogramToHistogramProto(0, generateTestHistogram(1)),
prompb.FromIntHistogram(0, generateTestHistogram(1)),
},
},
{
Labels: []prompb.Label{
{Name: "__name__", Value: "test_float_metric_seconds"},
},
Histograms: []prompb.Histogram{
remote.FloatHistogramToHistogramProto(0, generateTestFloatHistogram(2)),
prompb.FromFloatHistogram(0, generateTestFloatHistogram(2)),
},
},
},
Expand Down

0 comments on commit 1d4fa5f

Please sign in to comment.