micro-meter-prometheus/summary.go
Vasiliy Tolstov da9201efff
Some checks failed
codeql / analyze (go) (push) Failing after 35s
build / test (push) Failing after 4m53s
build / lint (push) Successful in 9m30s
lower memory usage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-10-06 13:45:33 +03:00

25 lines
474 B
Go

package prometheus
import (
"sync/atomic"
"time"
dto "github.com/prometheus/client_model/go"
)
type prometheusSummary struct {
name string
c *dto.Metric
}
func (c prometheusSummary) Update(n float64) {
atomic.AddUint64(c.c.Summary.SampleCount, 1)
addFloat64(c.c.Summary.SampleSum, n)
}
func (c prometheusSummary) UpdateDuration(n time.Time) {
x := time.Since(n).Seconds()
atomic.AddUint64(c.c.Summary.SampleCount, 1)
addFloat64(c.c.Summary.SampleSum, x)
}