|
29 | 29 | import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
30 | 30 | import io.opentelemetry.semconv.incubating.ServiceIncubatingAttributes;
|
31 | 31 | import java.net.URI;
|
| 32 | +import java.util.ArrayList; |
32 | 33 | import java.util.Arrays;
|
33 | 34 | import java.util.Collections;
|
34 | 35 | import java.util.List;
|
@@ -220,24 +221,28 @@ void shouldSendTelemetry() {
|
220 | 221 | AbstractIterableAssert::isNotEmpty);
|
221 | 222 |
|
222 | 223 | // JMX based metrics
|
223 |
| - Arrays.asList( |
224 |
| - "jvm.memory.used", |
225 |
| - "jvm.system.cpu.load_1m", |
226 |
| - "jvm.buffer.memory.usage", |
227 |
| - "jvm.memory.init") |
228 |
| - .forEach( |
229 |
| - metricName -> |
230 |
| - testing.waitAndAssertMetrics( |
231 |
| - "io.opentelemetry.runtime-telemetry-java8", |
232 |
| - metricName, |
233 |
| - AbstractIterableAssert::isNotEmpty)); |
| 224 | + List<String> jmxMetrics = |
| 225 | + new ArrayList<>( |
| 226 | + Arrays.asList("jvm.memory.used", "jvm.system.cpu.load_1m", "jvm.memory.init")); |
| 227 | + |
| 228 | + boolean noNative = System.getProperty("org.graalvm.nativeimage.imagecode") == null; |
| 229 | + if (noNative) { |
| 230 | + // GraalVM native image does not support buffer pools - have to investigate why |
| 231 | + jmxMetrics.add("jvm.buffer.memory.usage"); |
| 232 | + } |
| 233 | + jmxMetrics.forEach( |
| 234 | + metricName -> |
| 235 | + testing.waitAndAssertMetrics( |
| 236 | + "io.opentelemetry.runtime-telemetry-java8", |
| 237 | + metricName, |
| 238 | + AbstractIterableAssert::isNotEmpty)); |
234 | 239 |
|
235 | 240 | assertAdditionalMetrics();
|
236 | 241 |
|
237 | 242 | // Log
|
238 | 243 | List<LogRecordData> exportedLogRecords = testing.getExportedLogRecords();
|
239 | 244 | assertThat(exportedLogRecords).as("No log record exported.").isNotEmpty();
|
240 |
| - if (System.getProperty("org.graalvm.nativeimage.imagecode") == null) { |
| 245 | + if (noNative) { |
241 | 246 | // log records differ in native image mode due to different startup timing
|
242 | 247 | LogRecordData firstLog = exportedLogRecords.get(0);
|
243 | 248 | assertThat(firstLog.getBodyValue().asString())
|
|
0 commit comments