Add metric type to metric struct.
This commit is contained in:
parent
7e90814fde
commit
c34babeaf8
@ -48,7 +48,7 @@ func (a *Application) parse(body string) map[string]models.Metric {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
metric := models.NewMetric(name, "", params)
|
metric := models.NewMetric(name, "", "", params)
|
||||||
metric.SetValue(value)
|
metric.SetValue(value)
|
||||||
|
|
||||||
data[name] = metric
|
data[name] = metric
|
||||||
|
@ -8,15 +8,18 @@ type Metric struct {
|
|||||||
Description string
|
Description string
|
||||||
// Additional parameters, data inside "{}".
|
// Additional parameters, data inside "{}".
|
||||||
Params []string
|
Params []string
|
||||||
|
// Type is a metric type.
|
||||||
|
Type string
|
||||||
// Metric value.
|
// Metric value.
|
||||||
Value string
|
Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMetric creates new structure for storing single metric data.
|
// NewMetric creates new structure for storing single metric data.
|
||||||
func NewMetric(name, description string, params []string) Metric {
|
func NewMetric(name, mType, description string, params []string) Metric {
|
||||||
m := Metric{
|
m := Metric{
|
||||||
Name: name,
|
Name: name,
|
||||||
Description: description,
|
Description: description,
|
||||||
|
Type: mType,
|
||||||
Params: params,
|
Params: params,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ func (s *Storage) Get(key string) (models.Metric, error) {
|
|||||||
|
|
||||||
data, found := s.data[key]
|
data, found := s.data[key]
|
||||||
if !found {
|
if !found {
|
||||||
return models.NewMetric("", "", nil), ErrMetricNotFound
|
return models.NewMetric("", "", "", nil), ErrMetricNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
return data, nil
|
return data, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user