~mna/webparts-expvar

6290e0ddbb438214f7441dd4bf9d2629dc133d06 — Martin Angers 3 years ago bb965ef master
remove histogram
2 files changed, 2 insertions(+), 22 deletions(-)

M expvar.go
M expvar_test.go
M expvar.go => expvar.go +2 -13
@@ 1,5 1,6 @@
// Package expvar implements the webparts/metric standard interface using the
// expvar standard library package.
// expvar standard library package. The Histogram metric is not useful with expvar
// as there is no way to visualize it usefully, so it is not implemented.
package expvar

import (


@@ 51,15 52,3 @@ func (g *gauge) Add(delta float64) {
func (g *gauge) Set(value float64) {
	(*expvar.Float)(g).Set(value)
}

// NewHistogram creates a new histogram with the specified name. It panics if the
// name is already used for another metric.
func NewHistogram(name string) metric.Histogram {
	return (*histogram)(expvar.NewFloat(name))
}

type histogram expvar.Float

func (h *histogram) Observe(value float64) {
	(*expvar.Float)(h).Set(value)
}

M expvar_test.go => expvar_test.go +0 -9
@@ 32,12 32,3 @@ func TestGauge(t *testing.T) {
	g.Dec()
	require.Equal(t, "6", (*expvar.Float)(g.(*gauge)).String())
}

func TestHistogram(t *testing.T) {
	h := NewHistogram("histogram")

	h.Observe(1)
	h.Observe(3)
	h.Observe(-2)
	require.Equal(t, "-2", (*expvar.Float)(h.(*histogram)).String())
}