|
15 | 15 | import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
|
16 | 16 | import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
|
17 | 17 | import io.opentelemetry.javaagent.instrumentation.spring.actuator.v2_0.SpringApp.TestBean;
|
| 18 | +import java.util.Collection; |
| 19 | +import org.assertj.core.api.AbstractCollectionAssert; |
| 20 | +import org.assertj.core.api.ObjectAssert; |
18 | 21 | import org.junit.jupiter.api.Test;
|
19 | 22 | import org.junit.jupiter.api.extension.RegisterExtension;
|
20 | 23 | import org.springframework.boot.SpringApplication;
|
@@ -57,9 +60,19 @@ void shouldInjectOtelMeterRegistry() {
|
57 | 60 | "value"))))));
|
58 | 61 |
|
59 | 62 | MeterRegistry meterRegistry = context.getBean(MeterRegistry.class);
|
60 |
| - assertThat(meterRegistry).isNotNull().isInstanceOf(CompositeMeterRegistry.class); |
61 |
| - assertThat(((CompositeMeterRegistry) meterRegistry).getRegistries()) |
62 |
| - .anyMatch(r -> r.getClass().getSimpleName().equals("OpenTelemetryMeterRegistry")) |
63 |
| - .anyMatch(r -> r.getClass().getSimpleName().equals("SimpleMeterRegistry")); |
| 63 | + assertThat(meterRegistry).isInstanceOf(CompositeMeterRegistry.class); |
| 64 | + AbstractCollectionAssert< |
| 65 | + ?, Collection<? extends MeterRegistry>, MeterRegistry, ObjectAssert<MeterRegistry>> |
| 66 | + match = |
| 67 | + assertThat(((CompositeMeterRegistry) meterRegistry).getRegistries()) |
| 68 | + .anyMatch(r -> r.getClass().getSimpleName().equals("OpenTelemetryMeterRegistry")) |
| 69 | + .anyMatch(r -> r.getClass().getSimpleName().equals("SimpleMeterRegistry")); |
| 70 | + |
| 71 | + try { |
| 72 | + Class.forName("io.micrometer.prometheusmetrics.PrometheusMeterRegistry"); |
| 73 | + match.anyMatch(r -> r.getClass().getSimpleName().equals("PrometheusMeterRegistry")); |
| 74 | + } catch (ClassNotFoundException e) { |
| 75 | + // not testing prometheus |
| 76 | + } |
64 | 77 | }
|
65 | 78 | }
|
0 commit comments