Ignore tracking for metrics added to aggregator (#5508)

This commit is contained in:
Daniel Nelson
2019-03-01 11:21:31 -08:00
committed by GitHub
parent 2c09010f72
commit c57f2d9d48
2 changed files with 35 additions and 14 deletions

View File

@@ -62,6 +62,28 @@ func New(
return m, nil
}
// FromMetric returns a deep copy of the metric with any tracking information
// 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(),
}
for i, tag := range other.TagList() {
m.tags[i] = &telegraf.Tag{Key: tag.Key, Value: tag.Value}
}
for i, field := range other.FieldList() {
m.fields[i] = &telegraf.Field{Key: field.Key, Value: field.Value}
}
return m
}
func (m *metric) String() string {
return fmt.Sprintf("%s %v %v %d", m.name, m.Tags(), m.Fields(), m.tm.UnixNano())
}