From 2007064c474b9e90273819ed49c5ef2a142aeeb1 Mon Sep 17 00:00:00 2001 From: Ellison Marks Date: Thu, 22 Oct 2015 11:22:54 -0700 Subject: [PATCH] Fix for tags in the config not being applied to the agent. fixes #302 closes #308 --- CHANGELOG.md | 1 + config.go | 8 ++++---- config_test.go | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82c4db86e..4a4a34ace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ of metrics collected and from how many plugins. - [#264](https://github.com/influxdb/telegraf/issues/264): logrotate config file fixes. Thanks @linsomniac! - [#290](https://github.com/influxdb/telegraf/issues/290): Fix some plugins sending their values as strings. - [#289](https://github.com/influxdb/telegraf/issues/289): Fix accumulator panic on nil tags. +- [#302](https://github.com/influxdb/telegraf/issues/302): Fix `[tags]` getting applied, thanks @gotyaoi! ## v0.1.9 [2015-09-22] diff --git a/config.go b/config.go index 6853c99a8..60d97f4ff 100644 --- a/config.go +++ b/config.go @@ -21,7 +21,7 @@ import ( // specified type Config struct { // This lives outside the agent because mergeStruct doesn't need to handle maps normally. - // We just copy the elements manually in applyAgent. + // We just copy the elements manually in ApplyAgent. Tags map[string]string agent *Agent @@ -129,11 +129,11 @@ func (c *Config) ApplyOutput(name string, v interface{}) error { // Overrides only values in the given struct that were set in the config. func (c *Config) ApplyAgent(a *Agent) error { if c.agent != nil { + for key, value := range c.Tags { + a.Tags[key] = value + } return mergeStruct(a, c.agent, c.agentFieldsSet) } - for key, value := range c.Tags { - a.Tags[key] = value - } return nil } diff --git a/config_test.go b/config_test.go index 0d356f071..0e3c553e4 100644 --- a/config_test.go +++ b/config_test.go @@ -142,7 +142,6 @@ func (s *MergeStructSuite) TestFullMerge() { s.T().Error(err) } s.Equal(result, s.FullStruct, fmt.Sprintf("Full merge of %v onto FullStruct failed.", s.AnotherFullStruct)) - s.T().Log("hi") } func (s *MergeStructSuite) TestPartialMergeWithoutSlices() {