|
50 | 50 | import static io.helidon.webserver.observe.telemetry.metrics.OpenTelemetryMetricsHttpSemanticConventions.SOCKET_NAME; |
51 | 51 | import static org.hamcrest.MatcherAssert.assertThat; |
52 | 52 | import static org.hamcrest.Matchers.allOf; |
| 53 | +import static org.hamcrest.Matchers.containsString; |
53 | 54 | import static org.hamcrest.Matchers.greaterThan; |
54 | 55 | import static org.hamcrest.Matchers.hasEntry; |
55 | 56 | import static org.hamcrest.Matchers.hasItem; |
@@ -162,7 +163,8 @@ void checkAutoMetrics() { |
162 | 163 | and the timer's count is 1. |
163 | 164 | */ |
164 | 165 |
|
165 | | - List<String> jsonText = testLogHandler.messages(2); |
| 166 | + List<String> jsonText = testLogHandler.messages( |
| 167 | + hasItem(containsString(OpenTelemetryMetricsHttpSemanticConventions.TIMER_NAME))); |
166 | 168 |
|
167 | 169 | var root = JsonParser.create(jsonText.getFirst()).readJsonObject(); |
168 | 170 |
|
@@ -197,6 +199,16 @@ void checkAutoMetrics() { |
197 | 199 |
|
198 | 200 | for (JsonObject metricsEntry : metricsEntries) { |
199 | 201 |
|
| 202 | + /* |
| 203 | + OTel can insert some of its own messages, which we can ignore for this test. Skip any for which the |
| 204 | + metric name is not the name of our timer. |
| 205 | + */ |
| 206 | + var metricEntryName = metricsEntry.stringValue("name"); |
| 207 | + if (metricEntryName.isEmpty() |
| 208 | + || !metricEntryName.get().equals(OpenTelemetryMetricsHttpSemanticConventions.TIMER_NAME)) { |
| 209 | + continue; |
| 210 | + } |
| 211 | + |
200 | 212 | var dataPoints = metricsEntry.objectValue("histogram").orElseThrow() |
201 | 213 | .arrayValue("dataPoints").orElseThrow() |
202 | 214 | .values() |
|
0 commit comments