Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metrics/prometheus: fix for latest HEAD #885

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions metrics/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (

"github.com/go-kit/kit/metrics/teststat"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

func TestCounter(t *testing.T) {
s := httptest.NewServer(stdprometheus.UninstrumentedHandler())
s := httptest.NewServer(promhttp.HandlerFor(stdprometheus.DefaultGatherer, promhttp.HandlerOpts{}))
defer s.Close()

scrape := func() string {
Expand Down Expand Up @@ -48,7 +49,7 @@ func TestCounter(t *testing.T) {
}

func TestGauge(t *testing.T) {
s := httptest.NewServer(stdprometheus.UninstrumentedHandler())
s := httptest.NewServer(promhttp.HandlerFor(stdprometheus.DefaultGatherer, promhttp.HandlerOpts{}))
defer s.Close()

scrape := func() string {
Expand Down Expand Up @@ -79,7 +80,7 @@ func TestGauge(t *testing.T) {
}

func TestSummary(t *testing.T) {
s := httptest.NewServer(stdprometheus.UninstrumentedHandler())
s := httptest.NewServer(promhttp.HandlerFor(stdprometheus.DefaultGatherer, promhttp.HandlerOpts{}))
defer s.Close()

scrape := func() string {
Expand All @@ -94,10 +95,11 @@ func TestSummary(t *testing.T) {
re99 := regexp.MustCompile(namespace + `_` + subsystem + `_` + name + `{a="a",b="b",quantile="0.99"} ([0-9\.]+)`)

summary := NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: name,
Help: "This is the help string for the summary.",
Namespace: namespace,
Subsystem: subsystem,
Name: name,
Help: "This is the help string for the summary.",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
}, []string{"a", "b"}).With("b", "b").With("a", "a")

quantiles := func() (float64, float64, float64, float64) {
Expand All @@ -123,7 +125,7 @@ func TestHistogram(t *testing.T) {
// limit. That is, the count monotonically increases over the buckets. This
// requires a different strategy to test.

s := httptest.NewServer(stdprometheus.UninstrumentedHandler())
s := httptest.NewServer(promhttp.HandlerFor(stdprometheus.DefaultGatherer, promhttp.HandlerOpts{}))
defer s.Close()

scrape := func() string {
Expand Down Expand Up @@ -163,7 +165,6 @@ func TestHistogram(t *testing.T) {

// Then, we use ExpectedObservationsLessThan to validate.
for _, line := range strings.Split(scrape(), "\n") {
t.Logf("### %s", line)
match := re.FindStringSubmatch(line)
if match == nil {
continue
Expand Down