metrics/pcp: add unit to histogram
Suyash
7 years ago
94 | 94 |
// minimum observeable value is 0.
|
95 | 95 |
// maximum observeable value is 3600000000.
|
96 | 96 |
//
|
97 | |
// this requires a name parameter, and again, can take a couple of optional description strings.
|
98 | |
func (r *Reporter) NewHistogram(name string, min, max int64, desc ...string) (*Histogram, error) {
|
99 | |
h, err := speed.NewPCPHistogram(name, min, max, 5, desc...)
|
|
97 |
// The required parameters are a metric name,
|
|
98 |
// the minimum and maximum observable values,
|
|
99 |
// and a metric unit for the units of the observed values.
|
|
100 |
//
|
|
101 |
// Optionally, it can also take a couple of description strings.
|
|
102 |
func (r *Reporter) NewHistogram(name string, min, max int64, unit speed.MetricUnit, desc ...string) (*Histogram, error) {
|
|
103 |
h, err := speed.NewPCPHistogram(name, min, max, 5, unit, desc...)
|
100 | 104 |
if err != nil {
|
101 | 105 |
return nil, err
|
102 | 106 |
}
|
1 | 1 |
|
2 | 2 |
import (
|
3 | 3 |
"testing"
|
|
4 |
|
|
5 |
"github.com/performancecopilot/speed"
|
4 | 6 |
|
5 | 7 |
"github.com/go-kit/kit/metrics/teststat"
|
6 | 8 |
)
|
|
49 | 51 |
t.Fatal(err)
|
50 | 52 |
}
|
51 | 53 |
|
52 | |
histogram, err := r.NewHistogram("speed_histogram", 0, 3600000000)
|
|
54 |
histogram, err := r.NewHistogram("speed_histogram", 0, 3600000000, speed.OneUnit)
|
53 | 55 |
if err != nil {
|
54 | 56 |
t.Fatal(err)
|
55 | 57 |
}
|