2021-02-12 20:37:30 +03:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
type CounterMetric struct {
|
|
|
|
Name string
|
2022-03-18 20:20:13 +03:00
|
|
|
Value int64
|
2021-02-12 20:37:30 +03:00
|
|
|
Desc string
|
|
|
|
Labels Labels
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c CounterMetric) Key() string {
|
|
|
|
return c.Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c CounterMetric) Print() string {
|
|
|
|
return fmt.Sprintf("%s%s %d", c.Name, c.Labels.Print(), c.Value)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c CounterMetric) Header() string {
|
|
|
|
return fmt.Sprintf("# HELP %s %s\n# TYPE %s counter", c.Name, c.Desc, c.Name)
|
|
|
|
}
|