diff --git a/models/statistic.go b/models/statistic.go index 7e51a2c13d..8ce4a326c2 100644 --- a/models/statistic.go +++ b/models/statistic.go @@ -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{}), + } +} diff --git a/monitor/service.go b/monitor/service.go index 7c81794f74..6a9f827d91 100644 --- a/monitor/service.go +++ b/monitor/service.go @@ -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