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
}
// 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 {
u.lock.Lock()
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 {
// Inc increments labels.
Inc(lables ...string)
Inc(labels ...string)
// Add adds labels with v.
Add(v float64, labels ...string)
close() bool
@ -50,8 +50,8 @@ func (cv *promCounterVec) Inc(labels ...string) {
cv.counter.WithLabelValues(labels...).Inc()
}
func (cv *promCounterVec) Add(v float64, lables ...string) {
cv.counter.WithLabelValues(lables...).Add(v)
func (cv *promCounterVec) Add(v float64, labels ...string) {
cv.counter.WithLabelValues(labels...).Add(v)
}
func (cv *promCounterVec) close() bool {

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

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

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

Loading…
Cancel
Save