-
Notifications
You must be signed in to change notification settings - Fork 236
fix: adding missing tags for non k8s events #3256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| import java.io.*; | ||
| import java.net.HttpURLConnection; | ||
| import java.net.URL; | ||
| import java.net.URLEncoder; | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.time.Duration; | ||
| import java.util.ArrayDeque; | ||
|
|
@@ -226,24 +227,48 @@ private void verifyPrometheusMetrics() { | |
| "reconciliations_execution_duration_milliseconds_count", | ||
| Duration.ofSeconds(30)); | ||
|
|
||
| // First verify events_received_total exists at all (from ResourceEvents) | ||
| assertMetricPresent(prometheusUrl, "events_received_total", Duration.ofSeconds(30)); | ||
|
|
||
| // Verify timer event source events are recorded. | ||
| // Timer events are not ResourceEvents, so they get action="unknown". | ||
| // The namespace comes from the event's ResourceID (same as the associated resource). | ||
| // The "exported_namespace" label is used because OTel collector's | ||
| // resource_to_telemetry_conversion renames Micrometer's "namespace" tag. | ||
| assertMetricPresent( | ||
| prometheusUrl, | ||
| "events_received_total{action=\"unknown\"}", | ||
| Duration.ofSeconds(30), | ||
| "events_received_total", | ||
| "unknown"); | ||
|
|
||
| log.info("All metrics verified successfully in Prometheus"); | ||
| } | ||
|
|
||
| private void assertMetricPresent(String prometheusUrl, String metricName, Duration timeout) { | ||
| assertMetricPresent(prometheusUrl, metricName, timeout, metricName); | ||
| } | ||
|
|
||
| private void assertMetricPresent( | ||
| String prometheusUrl, String query, Duration timeout, String... expectedSubstrings) { | ||
| await() | ||
| .atMost(timeout) | ||
| .pollInterval(Duration.ofSeconds(5)) | ||
| .untilAsserted( | ||
| () -> { | ||
| String result = queryPrometheus(prometheusUrl, metricName); | ||
| log.info("{}: {}", metricName, result); | ||
| String result = queryPrometheus(prometheusUrl, query); | ||
| log.info("{}: {}", query, result); | ||
| assertThat(result).contains("\"status\":\"success\""); | ||
| assertThat(result).contains(metricName); | ||
| for (String expected : expectedSubstrings) { | ||
| log.info("Checking if result: {} contains expected: {}", result, expected); | ||
| assertThat(result).contains(expected); | ||
|
Comment on lines
+262
to
+264
|
||
| } | ||
| }); | ||
| } | ||
|
|
||
| private String queryPrometheus(String prometheusUrl, String query) throws IOException { | ||
| String urlString = prometheusUrl + "/api/v1/query?query=" + query; | ||
| String urlString = | ||
| prometheusUrl + "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8); | ||
| URL url = new URL(urlString); | ||
| HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||
| connection.setRequestMethod("GET"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.