2020-12-23 13:27:17 +05:00
|
|
|
package models
|
|
|
|
|
|
|
|
// Metric is a generic metric structure.
|
|
|
|
type Metric struct {
|
|
|
|
// Metric name.
|
2020-12-23 13:37:52 +05:00
|
|
|
Name string
|
2020-12-23 13:27:17 +05:00
|
|
|
// HELP data, if present.
|
2020-12-23 13:37:52 +05:00
|
|
|
Description string
|
2020-12-23 13:27:17 +05:00
|
|
|
// Additional parameters, data inside "{}".
|
2020-12-23 13:37:52 +05:00
|
|
|
Params []string
|
2020-12-23 13:27:17 +05:00
|
|
|
// Metric value.
|
2020-12-23 13:37:52 +05:00
|
|
|
Value string
|
2020-12-23 13:27:17 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewMetric creates new structure for storing single metric data.
|
|
|
|
func NewMetric(name, description string, params []string) Metric {
|
|
|
|
m := Metric{
|
2020-12-23 13:37:52 +05:00
|
|
|
Name: name,
|
|
|
|
Description: description,
|
|
|
|
Params: params,
|
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
|
|
|
}
|