Skip to content

Commit

Permalink
fix(telemetry_test/formatting): applies @jm96441n 's recommendations …
Browse files Browse the repository at this point in the history
…regarding prefix check on array
  • Loading branch information
Eclion committed Oct 11, 2024
1 parent 81d87ce commit c7b4679
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions telemetry/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"net"
"net/http"
"slices"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -97,13 +98,9 @@ func TestPrometheusMetrics(t *testing.T) {

missingActualMetrics := []string{}

prefixes := []string{"# HELP go_", "#TYPE go", "go_", "# HELP process_", "# TYPE process_", "process_"}
for _, actualMetric := range actualMetrics {
if strings.HasPrefix(actualMetric, "# HELP go_") ||
strings.HasPrefix(actualMetric, "# TYPE go_") ||
strings.HasPrefix(actualMetric, "go_") ||
strings.HasPrefix(actualMetric, "# HELP process_") ||
strings.HasPrefix(actualMetric, "# TYPE process_") ||
strings.HasPrefix(actualMetric, "process_") ||
if slices.ContainsFunc(prefixes, func(p string) bool { return strings.HasPrefix(actualMetric, p) }) ||
actualMetric == "" {
continue
}
Expand Down

0 comments on commit c7b4679

Please sign in to comment.