Fix metrics bucket key high cardinality
This commit is contained in:
parent
2d56be0ebb
commit
4da33c2bc2
4 changed files with 96 additions and 17 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"net/http"
|
||||
"net/http/httptest"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/go-kit/kit/metrics"
|
||||
|
@ -98,3 +99,33 @@ func TestCloseNotifier(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_getMethod(t *testing.T) {
|
||||
testCases := []struct {
|
||||
method string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
method: http.MethodGet,
|
||||
expected: http.MethodGet,
|
||||
},
|
||||
{
|
||||
method: strings.ToLower(http.MethodGet),
|
||||
expected: "EXTENSION_METHOD",
|
||||
},
|
||||
{
|
||||
method: "THIS_IS_NOT_A_VALID_METHOD",
|
||||
expected: "EXTENSION_METHOD",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
test := test
|
||||
t.Run(test.method, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
request := httptest.NewRequest(test.method, "http://example.com", nil)
|
||||
assert.Equal(t, test.expected, getMethod(request))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue