Remove Add() function from accumulator
This commit is contained in:
@@ -1478,19 +1478,23 @@ func (m *Mysql) gatherTableSchema(db *sql.DB, serv string, acc telegraf.Accumula
|
||||
tags["schema"] = tableSchema
|
||||
tags["table"] = tableName
|
||||
|
||||
acc.Add(newNamespace("info_schema", "table_rows"), tableRows, tags)
|
||||
acc.AddFields(newNamespace("info_schema", "table_rows"),
|
||||
map[string]interface{}{"value": tableRows}, tags)
|
||||
|
||||
dlTags := copyTags(tags)
|
||||
dlTags["component"] = "data_length"
|
||||
acc.Add(newNamespace("info_schema", "table_size", "data_length"), dataLength, dlTags)
|
||||
acc.AddFields(newNamespace("info_schema", "table_size", "data_length"),
|
||||
map[string]interface{}{"value": dataLength}, dlTags)
|
||||
|
||||
ilTags := copyTags(tags)
|
||||
ilTags["component"] = "index_length"
|
||||
acc.Add(newNamespace("info_schema", "table_size", "index_length"), indexLength, ilTags)
|
||||
acc.AddFields(newNamespace("info_schema", "table_size", "index_length"),
|
||||
map[string]interface{}{"value": indexLength}, ilTags)
|
||||
|
||||
dfTags := copyTags(tags)
|
||||
dfTags["component"] = "data_free"
|
||||
acc.Add(newNamespace("info_schema", "table_size", "data_free"), dataFree, dfTags)
|
||||
acc.AddFields(newNamespace("info_schema", "table_size", "data_free"),
|
||||
map[string]interface{}{"value": dataFree}, dfTags)
|
||||
|
||||
versionTags := copyTags(tags)
|
||||
versionTags["type"] = tableType
|
||||
@@ -1498,7 +1502,8 @@ func (m *Mysql) gatherTableSchema(db *sql.DB, serv string, acc telegraf.Accumula
|
||||
versionTags["row_format"] = rowFormat
|
||||
versionTags["create_options"] = createOptions
|
||||
|
||||
acc.Add(newNamespace("info_schema", "table_version"), version, versionTags)
|
||||
acc.AddFields(newNamespace("info_schema", "table_version"),
|
||||
map[string]interface{}{"value": version}, versionTags)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -166,7 +166,9 @@ func (s *SQLServer) accRow(query Query, acc telegraf.Accumulator, row scanner) e
|
||||
|
||||
if query.ResultByRow {
|
||||
// add measurement to Accumulator
|
||||
acc.Add(measurement, *columnMap["value"], tags, time.Now())
|
||||
acc.AddFields(measurement,
|
||||
map[string]interface{}{"value": *columnMap["value"]},
|
||||
tags, time.Now())
|
||||
} else {
|
||||
// values
|
||||
for header, val := range columnMap {
|
||||
@@ -290,8 +292,8 @@ IF OBJECT_ID('tempdb..#clerk') IS NOT NULL
|
||||
DROP TABLE #clerk;
|
||||
|
||||
CREATE TABLE #clerk (
|
||||
ClerkCategory nvarchar(64) NOT NULL,
|
||||
UsedPercent decimal(9,2),
|
||||
ClerkCategory nvarchar(64) NOT NULL,
|
||||
UsedPercent decimal(9,2),
|
||||
UsedBytes bigint
|
||||
);
|
||||
|
||||
|
||||
@@ -53,7 +53,9 @@ func TestSqlServer_ParseMetrics(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// add value to Accumulator
|
||||
acc.Add(measurement, value, tags, time.Now())
|
||||
acc.AddFields(measurement,
|
||||
map[string]interface{}{"value": value},
|
||||
tags, time.Now())
|
||||
// assert
|
||||
acc.AssertContainsTaggedFields(t, measurement, map[string]interface{}{"value": value}, tags)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ type PS interface {
|
||||
func add(acc telegraf.Accumulator,
|
||||
name string, val float64, tags map[string]string) {
|
||||
if val >= 0 {
|
||||
acc.Add(name, val, tags)
|
||||
acc.AddFields(name, map[string]interface{}{"value": val}, tags)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user