Remove deprecated and unused SetAggregate() and IsAggregate() functions. (#8994)

This commit is contained in:
Sven Rebhan 2021-04-06 18:14:06 +02:00 committed by GitHub
parent 0b0fc087c4
commit 5524acfb78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 43 deletions

View File

@ -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
}

View File

@ -15,8 +15,7 @@ type metric struct {
fields []*telegraf.Field
tm time.Time
tp telegraf.ValueType
aggregate bool
tp telegraf.ValueType
}
func New(
@ -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() {
@ -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 {
@ -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))

View File

@ -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())
}

View File

@ -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