metricator/internal/models/metric.go

38 lines
746 B
Go
Raw Normal View History

package models
// Metric is a generic metric structure.
type Metric struct {
// Metric name.
Name string
// HELP data, if present.
Description string
// Additional parameters, data inside "{}".
Params []string
2020-12-23 13:45:33 +05:00
// Type is a metric type.
Type string
// Metric value.
Value string
}
// 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 {
m := Metric{
Name: name,
Description: description,
2020-12-23 13:45:33 +05:00
Type: mType,
Params: params,
}
return m
}
// GetValue returns metric's value.
func (m *Metric) GetValue() string {
return m.Value
}
// SetValue sets value for metric.
func (m *Metric) SetValue(value string) {
m.Value = value
}