Skip to content

Commit

Permalink
map return order agent config bug fix
Browse files Browse the repository at this point in the history
closes #1090
  • Loading branch information
sparrc committed Apr 29, 2016
1 parent 9146043 commit 561b5b4
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,23 +446,41 @@ func (c *Config) LoadConfig(path string) error {
return fmt.Errorf("Error parsing %s, %s", path, err)
}

// Parse tags tables first:
for _, tableName := range []string{"tags", "global_tags"} {
if val, ok := tbl.Fields[tableName]; ok {
subTable, ok := val.(*ast.Table)
if !ok {
return fmt.Errorf("%s: invalid configuration", path)
}
if err = config.UnmarshalTable(subTable, c.Tags); err != nil {
log.Printf("Could not parse [global_tags] config\n")
return fmt.Errorf("Error parsing %s, %s", path, err)
}
}
}

// Parse agent table:
if val, ok := tbl.Fields["agent"]; ok {
subTable, ok := val.(*ast.Table)
if !ok {
return fmt.Errorf("%s: invalid configuration", path)
}
if err = config.UnmarshalTable(subTable, c.Agent); err != nil {
log.Printf("Could not parse [agent] config\n")
return fmt.Errorf("Error parsing %s, %s", path, err)
}
}

// Parse all the rest of the plugins:
for name, val := range tbl.Fields {
subTable, ok := val.(*ast.Table)
if !ok {
return fmt.Errorf("%s: invalid configuration", path)
}

switch name {
case "agent":
if err = config.UnmarshalTable(subTable, c.Agent); err != nil {
log.Printf("Could not parse [agent] config\n")
return fmt.Errorf("Error parsing %s, %s", path, err)
}
case "global_tags", "tags":
if err = config.UnmarshalTable(subTable, c.Tags); err != nil {
log.Printf("Could not parse [global_tags] config\n")
return fmt.Errorf("Error parsing %s, %s", path, err)
}
case "agent", "global_tags", "tags":
case "outputs":
for pluginName, pluginVal := range subTable.Fields {
switch pluginSubTable := pluginVal.(type) {
Expand Down Expand Up @@ -560,6 +578,7 @@ func (c *Config) addOutput(name string, table *ast.Table) error {
return err
}

log.Printf("Buffer Limit: %d\n", c.Agent.MetricBufferLimit)
ro := internal_models.NewRunningOutput(name, output, outputConfig,
c.Agent.MetricBatchSize, c.Agent.MetricBufferLimit)
c.Outputs = append(c.Outputs, ro)
Expand Down

0 comments on commit 561b5b4

Please sign in to comment.