Skip to content

Commit

Permalink
Remove deprecated and unused SetAggregate() and IsAggregate() functio…
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan authored Apr 6, 2021
1 parent 0b0fc08 commit 5524acf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 43 deletions.
10 changes: 0 additions & 10 deletions metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,4 @@ type Metric interface {
// Drop marks the metric as processed successfully without being written
// to any output.
Drop()

// SetAggregate indicates the metric is an aggregated value.
//
// This method may be removed in the future and its use is discouraged.
SetAggregate(bool)

// IsAggregate returns true if the Metric is an aggregate.
//
// This method may be removed in the future and its use is discouraged.
IsAggregate() bool
}
33 changes: 11 additions & 22 deletions metric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ type metric struct {
fields []*telegraf.Field
tm time.Time

tp telegraf.ValueType
aggregate bool
tp telegraf.ValueType
}

func New(
Expand Down Expand Up @@ -68,12 +67,11 @@ func New(
// removed.
func FromMetric(other telegraf.Metric) telegraf.Metric {
m := &metric{
name: other.Name(),
tags: make([]*telegraf.Tag, len(other.TagList())),
fields: make([]*telegraf.Field, len(other.FieldList())),
tm: other.Time(),
tp: other.Type(),
aggregate: other.IsAggregate(),
name: other.Name(),
tags: make([]*telegraf.Tag, len(other.TagList())),
fields: make([]*telegraf.Field, len(other.FieldList())),
tm: other.Time(),
tp: other.Type(),
}

for i, tag := range other.TagList() {
Expand Down Expand Up @@ -233,12 +231,11 @@ func (m *metric) SetTime(t time.Time) {

func (m *metric) Copy() telegraf.Metric {
m2 := &metric{
name: m.name,
tags: make([]*telegraf.Tag, len(m.tags)),
fields: make([]*telegraf.Field, len(m.fields)),
tm: m.tm,
tp: m.tp,
aggregate: m.aggregate,
name: m.name,
tags: make([]*telegraf.Tag, len(m.tags)),
fields: make([]*telegraf.Field, len(m.fields)),
tm: m.tm,
tp: m.tp,
}

for i, tag := range m.tags {
Expand All @@ -251,14 +248,6 @@ func (m *metric) Copy() telegraf.Metric {
return m2
}

func (m *metric) SetAggregate(aggregate bool) {
m.aggregate = aggregate
}

func (m *metric) IsAggregate() bool {
return m.aggregate
}

func (m *metric) HashID() uint64 {
h := fnv.New64a()
h.Write([]byte(m.name))
Expand Down
7 changes: 0 additions & 7 deletions metric/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,3 @@ func TestValueType(t *testing.T) {

assert.Equal(t, telegraf.Gauge, m.Type())
}

func TestCopyAggregate(t *testing.T) {
m1 := baseMetric()
m1.SetAggregate(true)
m2 := m1.Copy()
assert.True(t, m2.IsAggregate())
}
4 changes: 0 additions & 4 deletions models/running_aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ func (r *RunningAggregator) MakeMetric(metric telegraf.Metric) telegraf.Metric {
r.Config.Tags,
nil)

if m != nil {
m.SetAggregate(true)
}

r.MetricsPushed.Incr(1)

return m
Expand Down

0 comments on commit 5524acf

Please sign in to comment.