prometheus metric updates tests

pull/668/head
hunterlong 2020-06-16 05:15:12 -07:00
parent de144b67dd
commit 91efe7db63
2 changed files with 6 additions and 4 deletions

View File

@ -248,9 +248,9 @@ func TestMainApiRoutes(t *testing.T) {
ExpectedContains: []string{ ExpectedContains: []string{
`go_goroutines`, `go_goroutines`,
`go_memstats_alloc_bytes`, `go_memstats_alloc_bytes`,
`http_duration_seconds_count`, `statping_service_success`,
`http_response_bytes_count`, `statping_http_duration_seconds`,
`service_success`, `statping_service_duration_count`,
}, },
}, },
} }

View File

@ -26,7 +26,7 @@ type scope struct {
scope string scope string
} }
// MarshalJSON for Scopr // TODO: make a better way to parse
func (s scope) MarshalJSON() ([]byte, error) { func (s scope) MarshalJSON() ([]byte, error) {
svc := reflect.ValueOf(s.data) svc := reflect.ValueOf(s.data)
if svc.Kind() == reflect.Slice { if svc.Kind() == reflect.Slice {
@ -40,6 +40,7 @@ func (s scope) MarshalJSON() ([]byte, error) {
return json.Marshal(SafeJson(svc, s.scope)) return json.Marshal(SafeJson(svc, s.scope))
} }
// TODO: make a better way to parse
func SafeJson(val reflect.Value, scope string) map[string]interface{} { func SafeJson(val reflect.Value, scope string) map[string]interface{} {
thisData := make(map[string]interface{}) thisData := make(map[string]interface{})
if val.Kind() == reflect.Interface && !val.IsNil() { if val.Kind() == reflect.Interface && !val.IsNil() {
@ -89,6 +90,7 @@ func SafeJson(val reflect.Value, scope string) map[string]interface{} {
return thisData return thisData
} }
// TODO: make a better way to parse
func forTag(tags []string, scope string) bool { func forTag(tags []string, scope string) bool {
for _, v := range tags { for _, v := range tags {
if v == scope { if v == scope {