fix some typo (#667)

master
heyanfu 4 years ago committed by GitHub
parent 9a44310d00
commit 97d889103a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -36,7 +36,7 @@ func (u Unstable) AroundDuration(base time.Duration) time.Duration {
return val return val
} }
// AroundInt returns a randome int64 with given base and deviation. // AroundInt returns a random int64 with given base and deviation.
func (u Unstable) AroundInt(base int64) int64 { func (u Unstable) AroundInt(base int64) int64 {
u.lock.Lock() u.lock.Lock()
val := int64((1 + u.deviation - 2*u.deviation*u.r.Float64()) * float64(base)) val := int64((1 + u.deviation - 2*u.deviation*u.r.Float64()) * float64(base))

@ -12,7 +12,7 @@ type (
// CounterVec interface represents a counter vector. // CounterVec interface represents a counter vector.
CounterVec interface { CounterVec interface {
// Inc increments labels. // Inc increments labels.
Inc(lables ...string) Inc(labels ...string)
// Add adds labels with v. // Add adds labels with v.
Add(v float64, labels ...string) Add(v float64, labels ...string)
close() bool close() bool
@ -50,8 +50,8 @@ func (cv *promCounterVec) Inc(labels ...string) {
cv.counter.WithLabelValues(labels...).Inc() cv.counter.WithLabelValues(labels...).Inc()
} }
func (cv *promCounterVec) Add(v float64, lables ...string) { func (cv *promCounterVec) Add(v float64, labels ...string) {
cv.counter.WithLabelValues(lables...).Add(v) cv.counter.WithLabelValues(labels...).Add(v)
} }
func (cv *promCounterVec) close() bool { func (cv *promCounterVec) close() bool {

@ -20,7 +20,7 @@ type (
close() bool close() bool
} }
promGuageVec struct { promGaugeVec struct {
gauge *prom.GaugeVec gauge *prom.GaugeVec
} }
) )
@ -39,7 +39,7 @@ func NewGaugeVec(cfg *GaugeVecOpts) GaugeVec {
Help: cfg.Help, Help: cfg.Help,
}, cfg.Labels) }, cfg.Labels)
prom.MustRegister(vec) prom.MustRegister(vec)
gv := &promGuageVec{ gv := &promGaugeVec{
gauge: vec, gauge: vec,
} }
proc.AddShutdownListener(func() { proc.AddShutdownListener(func() {
@ -49,18 +49,18 @@ func NewGaugeVec(cfg *GaugeVecOpts) GaugeVec {
return gv return gv
} }
func (gv *promGuageVec) Inc(labels ...string) { func (gv *promGaugeVec) Inc(labels ...string) {
gv.gauge.WithLabelValues(labels...).Inc() gv.gauge.WithLabelValues(labels...).Inc()
} }
func (gv *promGuageVec) Add(v float64, lables ...string) { func (gv *promGaugeVec) Add(v float64, labels ...string) {
gv.gauge.WithLabelValues(lables...).Add(v) gv.gauge.WithLabelValues(labels...).Add(v)
} }
func (gv *promGuageVec) Set(v float64, lables ...string) { func (gv *promGaugeVec) Set(v float64, labels ...string) {
gv.gauge.WithLabelValues(lables...).Set(v) gv.gauge.WithLabelValues(labels...).Set(v)
} }
func (gv *promGuageVec) close() bool { func (gv *promGaugeVec) close() bool {
return prom.Unregister(gv.gauge) return prom.Unregister(gv.gauge)
} }

@ -29,7 +29,7 @@ func TestGaugeInc(t *testing.T) {
Labels: []string{"path"}, Labels: []string{"path"},
}) })
defer gaugeVec.close() defer gaugeVec.close()
gv, _ := gaugeVec.(*promGuageVec) gv, _ := gaugeVec.(*promGaugeVec)
gv.Inc("/users") gv.Inc("/users")
gv.Inc("/users") gv.Inc("/users")
r := testutil.ToFloat64(gv.gauge) r := testutil.ToFloat64(gv.gauge)
@ -45,7 +45,7 @@ func TestGaugeAdd(t *testing.T) {
Labels: []string{"path"}, Labels: []string{"path"},
}) })
defer gaugeVec.close() defer gaugeVec.close()
gv, _ := gaugeVec.(*promGuageVec) gv, _ := gaugeVec.(*promGaugeVec)
gv.Add(-10, "/classroom") gv.Add(-10, "/classroom")
gv.Add(30, "/classroom") gv.Add(30, "/classroom")
r := testutil.ToFloat64(gv.gauge) r := testutil.ToFloat64(gv.gauge)
@ -61,7 +61,7 @@ func TestGaugeSet(t *testing.T) {
Labels: []string{"path"}, Labels: []string{"path"},
}) })
gaugeVec.close() gaugeVec.close()
gv, _ := gaugeVec.(*promGuageVec) gv, _ := gaugeVec.(*promGaugeVec)
gv.Set(666, "/users") gv.Set(666, "/users")
r := testutil.ToFloat64(gv.gauge) r := testutil.ToFloat64(gv.gauge)
assert.Equal(t, float64(666), r) assert.Equal(t, float64(666), r)

@ -19,7 +19,7 @@ type (
// A HistogramVec interface represents a histogram vector. // A HistogramVec interface represents a histogram vector.
HistogramVec interface { HistogramVec interface {
// Observe adds observation v to labels. // Observe adds observation v to labels.
Observe(v int64, lables ...string) Observe(v int64, labels ...string)
close() bool close() bool
} }

Loading…
Cancel
Save