mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 04:04:00 -06:00
9e78faa7ba
* Alerting: Add metrics to the remote Alertmanager struct * rephrase http_requests_failed description * make linter happy * remove unnecessary metrics * extract timed client to separate package * use histogram collector from dskit * remove weaveworks dependency * capture metrics for all requests to the remote Alertmanager (both clients) * use the timed client in the MimirAuthRoundTripper * HTTPRequestsDuration -> HTTPRequestDuration, clean up mimir client factory function * refactor * less git diff * gauge for last readiness check in seconds * initialize LastReadinesCheck to 0, tweak metric names and descriptions * add counters for sync attempts/errors * last config sync and last state sync timestamps (gauges) * change latency metric name * metric for remote Alertmanager mode * code review comments * move label constants to metrics package
30 lines
724 B
Go
30 lines
724 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestTimedClient_operationName(t *testing.T) {
|
|
r, err := http.NewRequest("GET", "https://weave.test", nil)
|
|
assert.NoError(t, err)
|
|
|
|
r = r.WithContext(context.WithValue(context.Background(), OperationNameContextKey, "opp"))
|
|
c := NewTimedClient(http.DefaultClient, nil)
|
|
|
|
assert.Equal(t, "opp", c.operationName(r))
|
|
}
|
|
|
|
func TestTimedClient_operationName_Default(t *testing.T) {
|
|
r, err := http.NewRequest("GET", "https://weave.test/you/know/me", nil)
|
|
assert.NoError(t, err)
|
|
|
|
r = r.WithContext(context.Background())
|
|
c := NewTimedClient(http.DefaultClient, nil)
|
|
|
|
assert.Equal(t, "/you/know/me", c.operationName(r))
|
|
}
|