2020-12-23 13:27:17 +05:00
|
|
|
package models
|
|
|
|
|
|
|
|
// Metric is a generic metric structure.
|
|
|
|
type Metric struct {
|
2020-12-23 22:12:25 +05:00
|
|
|
// BaseName is a metric's base name, used for constructing name.
|
|
|
|
BaseName string
|
2020-12-23 19:31:09 +05:00
|
|
|
// Name is a metric name.
|
2020-12-23 13:37:52 +05:00
|
|
|
Name string
|
2020-12-23 19:31:09 +05:00
|
|
|
// Description is a metric description from HELP line.
|
2020-12-23 13:37:52 +05:00
|
|
|
Description string
|
2020-12-23 19:31:09 +05:00
|
|
|
// Type is a metric type from TYPE line.
|
2020-12-23 13:45:33 +05:00
|
|
|
Type string
|
2020-12-23 19:31:09 +05:00
|
|
|
// Value is a metric value.
|
2020-12-23 13:37:52 +05:00
|
|
|
Value string
|
2020-12-23 19:31:09 +05:00
|
|
|
// Params is an additional params which are placed inside "{}".
|
|
|
|
Params []string
|
2020-12-23 13:27:17 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewMetric creates new structure for storing single metric data.
|
2020-12-23 13:45:33 +05:00
|
|
|
func NewMetric(name, mType, description string, params []string) Metric {
|
2020-12-23 13:27:17 +05:00
|
|
|
m := Metric{
|
2020-12-23 22:12:25 +05:00
|
|
|
BaseName: name,
|
2020-12-23 13:37:52 +05:00
|
|
|
Name: name,
|
|
|
|
Description: description,
|
2020-12-23 13:45:33 +05:00
|
|
|
Type: mType,
|
2020-12-23 13:37:52 +05:00
|
|
|
Params: params,
|
2020-12-23 19:31:09 +05:00
|
|
|
Value: "",
|
2020-12-23 13:27:17 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetValue returns metric's value.
|
|
|
|
func (m *Metric) GetValue() string {
|
2020-12-23 13:37:52 +05:00
|
|
|
return m.Value
|
2020-12-23 13:27:17 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetValue sets value for metric.
|
|
|
|
func (m *Metric) SetValue(value string) {
|
2020-12-23 13:37:52 +05:00
|
|
|
m.Value = value
|
2020-12-23 13:27:17 +05:00
|
|
|
}
|