Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
feat: expose percentiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Cescon de Moura committed Jul 3, 2018
1 parent 98f1aee commit f7af88e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type Reporter struct {
// DefaultValues are the values that will be sent in all submits.
DefaultValues map[string]interface{}
Version string

percentiles []float64
// Percentiles to be sent on histograms and timers
Percentiles []float64
}

// NewReporter creates a new Reporter for the register r, with an UDP client to
Expand All @@ -47,7 +47,7 @@ func NewReporter(r metrics.Registry, addr string, defaultValues map[string]inter
DefaultValues: defaultValues,
Version: "0.1.1",

percentiles: []float64{0.50, 0.75, 0.95, 0.99, 0.999},
Percentiles: []float64{0.50, 0.75, 0.95, 0.99, 0.999},
}, nil
}

Expand Down Expand Up @@ -95,7 +95,7 @@ func (r *Reporter) FlushOnce() error {
m[fmt.Sprintf("%s.stddev", name)] = ms.StdDev()
m[fmt.Sprintf("%s.var", name)] = ms.Variance()

for _, p := range r.percentiles {
for _, p := range r.Percentiles {
pStr := strings.Replace(fmt.Sprintf("p%g", p*100), ".", "_", -1)
m[fmt.Sprintf("%s.%s", name, pStr)] = ms.Percentile(p)
}
Expand All @@ -116,7 +116,7 @@ func (r *Reporter) FlushOnce() error {
m[fmt.Sprintf("%s.mean", name)] = time.Duration(ms.Mean()).Seconds() * 1000
m[fmt.Sprintf("%s.stddev", name)] = time.Duration(ms.StdDev()).Seconds() * 1000

for _, p := range r.percentiles {
for _, p := range r.Percentiles {
duration := time.Duration(ms.Percentile(p)).Seconds() * 1000
pStr := strings.Replace(fmt.Sprintf("p%g", p*100), ".", "_", -1)
m[fmt.Sprintf("%s.%s", name, pStr)] = duration
Expand Down

0 comments on commit f7af88e

Please sign in to comment.