Merge pull request #7193 from influxdata/2016-08-23-fix-panic-monitor-service

Fix "nil map" panic in statistics collection.
pull/7203/head
Edd Robinson 2016-08-24 10:53:50 +01:00 committed by GitHub
commit 3ecc913c88
2 changed files with 10 additions and 7 deletions

View File

@ -5,3 +5,11 @@ type Statistic struct {
Tags map[string]string `json:"tags"`
Values map[string]interface{} `json:"values"`
}
func NewStatistic(name string) Statistic {
return Statistic{
Name: name,
Tags: make(map[string]string),
Values: make(map[string]interface{}),
}
}

View File

@ -210,9 +210,7 @@ func (m *Monitor) Statistics(tags map[string]string) ([]*Statistic, error) {
}
statistic := &Statistic{
Statistic: models.Statistic{
Values: make(map[string]interface{}),
},
Statistic: models.NewStatistic(""),
}
// Add any supplied tags.
@ -277,10 +275,7 @@ func (m *Monitor) Statistics(tags map[string]string) ([]*Statistic, error) {
// Add Go memstats.
statistic := &Statistic{
Statistic: models.Statistic{
Name: "runtime",
Values: make(map[string]interface{}),
},
Statistic: models.NewStatistic("runtime"),
}
// Add any supplied tags to Go memstats