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{
`go_goroutines`,
`go_memstats_alloc_bytes`,
`http_duration_seconds_count`,
`http_response_bytes_count`,
`service_success`,
`statping_service_success`,
`statping_http_duration_seconds`,
`statping_service_duration_count`,
},
},
}

View File

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