MCPcopy Index your code
hub / github.com/cortexproject/cortex / assertServiceMetricsPrefixes

Function assertServiceMetricsPrefixes

integration/asserts.go:55–82  ·  view source on GitHub ↗
(t *testing.T, serviceType ServiceType, service *e2ecortex.CortexService)

Source from the content-addressed store, hash-verified

53)
54
55func assertServiceMetricsPrefixes(t *testing.T, serviceType ServiceType, service *e2ecortex.CortexService) {
56 if service == nil {
57 return
58 }
59
60 metrics, err := service.Metrics()
61 require.NoError(t, err)
62
63 // Build the list of blacklisted metrics prefixes for this specific service.
64 blacklist := getBlacklistedMetricsPrefixesByService(serviceType)
65
66 // Ensure no metric name matches the blacklisted prefixes.
67 for _, metricLine := range strings.Split(metrics, "\n") {
68 metricLine = strings.TrimSpace(metricLine)
69 if metricLine == "" || strings.HasPrefix(metricLine, "#") {
70 continue
71 }
72
73 for _, prefix := range blacklist {
74 // Skip the metric if it matches an ignored prefix.
75 if prefix[0] == '!' && strings.HasPrefix(metricLine, prefix[1:]) {
76 break
77 }
78
79 assert.NotRegexp(t, "^"+prefix, metricLine, "service: %s endpoint: %s", service.Name(), service.HTTPEndpoint())
80 }
81 }
82}
83
84func getBlacklistedMetricsPrefixesByService(serviceType ServiceType) []string {
85 blacklist := append([]string{}, blacklistedMetricsPrefixes...)

Calls 4

MetricsMethod · 0.80
HTTPEndpointMethod · 0.80
NameMethod · 0.65