10 | 10 |
c *speed.PCPClient
|
11 | 11 |
}
|
12 | 12 |
|
13 | |
// NewReporter creates a new Reporter instance.
|
14 | |
// The first parameter is the application name and is used to create
|
15 | |
// the speed client. Hence it should be a valid speed parameter name and
|
16 | |
// should not contain spaces or the path separator for your operating system.
|
|
13 |
// NewReporter creates a new Reporter instance. The first parameter is the
|
|
14 |
// application name and is used to create the speed client. Hence it should be a
|
|
15 |
// valid speed parameter name and should not contain spaces or the path
|
|
16 |
// separator for your operating system.
|
17 | 17 |
func NewReporter(appname string) (*Reporter, error) {
|
18 | 18 |
c, err := speed.NewPCPClient(appname)
|
19 | 19 |
if err != nil {
|
|
36 | 36 |
c speed.Counter
|
37 | 37 |
}
|
38 | 38 |
|
39 | |
// NewCounter creates a new Counter.
|
40 | |
//
|
41 | |
// This requires a name parameter and can optionally take a couple of
|
42 | |
// description strings, that are used to create the underlying speed.Counter
|
43 | |
// and are reported by PCP.
|
|
39 |
// NewCounter creates a new Counter. This requires a name parameter and can
|
|
40 |
// optionally take a couple of description strings, that are used to create the
|
|
41 |
// underlying speed.Counter and are reported by PCP.
|
44 | 42 |
func (r *Reporter) NewCounter(name string, desc ...string) (*Counter, error) {
|
45 | 43 |
c, err := speed.NewPCPCounter(0, name, desc...)
|
46 | 44 |
if err != nil {
|
|
54 | 52 |
// With is a no-op.
|
55 | 53 |
func (c *Counter) With(labelValues ...string) metrics.Counter { return c }
|
56 | 54 |
|
57 | |
// Add increments Counter.
|
58 | |
// speed Counters only take int64, so delta is converted to int64 before
|
59 | |
// observation. speed Gauges can take float64 and `Add(float64)`
|
60 | |
// is implemented by metrics.Gauge.
|
|
55 |
// Add increments Counter. speed.Counters only take int64, so delta is converted
|
|
56 |
// to int64 before observation.
|
61 | 57 |
func (c *Counter) Add(delta float64) { c.c.Inc(int64(delta)) }
|
62 | 58 |
|
63 | 59 |
// Gauge implements metrics.Gauge via a single dimensional speed.Gauge.
|
|
65 | 61 |
g speed.Gauge
|
66 | 62 |
}
|
67 | 63 |
|
68 | |
// NewGauge creates a new Gauge.
|
69 | |
//
|
70 | |
// This requires a name parameter, and again, can take a couple of
|
71 | |
// optional description strings.
|
|
64 |
// NewGauge creates a new Gauge. This requires a name parameter and can
|
|
65 |
// optionally take a couple of description strings, that are used to create the
|
|
66 |
// underlying speed.Gauge and are reported by PCP.
|
72 | 67 |
func (r *Reporter) NewGauge(name string, desc ...string) (*Gauge, error) {
|
73 | 68 |
g, err := speed.NewPCPGauge(0, name, desc...)
|
74 | 69 |
if err != nil {
|
|
93 | 88 |
h speed.Histogram
|
94 | 89 |
}
|
95 | 90 |
|
96 | |
// NewHistogram creates a new Histogram.
|
97 | |
// Minimum observeable value is 0.
|
98 | |
// Maximum observeable value is 3600000000.
|
|
91 |
// NewHistogram creates a new Histogram. The minimum observeable value is 0. The
|
|
92 |
// maximum observeable value is 3600000000 (3.6e9).
|
99 | 93 |
//
|
100 | |
// The required parameters are a metric name,
|
101 | |
// the minimum and maximum observable values,
|
102 | |
// and a metric unit for the units of the observed values.
|
|
94 |
// The required parameters are a metric name, the minimum and maximum observable
|
|
95 |
// values, and a metric unit for the units of the observed values.
|
103 | 96 |
//
|
104 | 97 |
// Optionally, it can also take a couple of description strings.
|
105 | 98 |
func (r *Reporter) NewHistogram(name string, min, max int64, unit speed.MetricUnit, desc ...string) (*Histogram, error) {
|