diff --git a/core/mathx/unstable.go b/core/mathx/unstable.go index 23eccc39..33dfda5a 100644 --- a/core/mathx/unstable.go +++ b/core/mathx/unstable.go @@ -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)) diff --git a/core/metric/counter.go b/core/metric/counter.go index f34700cf..aecbe373 100644 --- a/core/metric/counter.go +++ b/core/metric/counter.go @@ -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 { diff --git a/core/metric/gauge.go b/core/metric/gauge.go index ae08bb8f..01fbfe80 100644 --- a/core/metric/gauge.go +++ b/core/metric/gauge.go @@ -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) } diff --git a/core/metric/gauge_test.go b/core/metric/gauge_test.go index 3a504c15..534889fb 100644 --- a/core/metric/gauge_test.go +++ b/core/metric/gauge_test.go @@ -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) diff --git a/core/metric/histogram.go b/core/metric/histogram.go index 0f759e91..59513db8 100644 --- a/core/metric/histogram.go +++ b/core/metric/histogram.go @@ -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 }