Skip to content

Commit

Permalink
Fix flaky MetricExporterConfigurationTest (#5877)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Oct 5, 2023
1 parent c39ebfe commit 533c30a
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@

class MetricExporterConfigurationTest {

private static final ConfigProperties EMPTY =
DefaultConfigProperties.createFromMap(Collections.emptyMap());
private static final ConfigProperties CONFIG_PROPERTIES =
DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.prometheus.port", "0"));

@RegisterExtension CleanupExtension cleanup = new CleanupExtension();

Expand All @@ -48,7 +49,7 @@ void configureReader_PrometheusOnClasspath() {

MetricReader reader =
MetricExporterConfiguration.configureReader(
"prometheus", EMPTY, spiHelper, (a, b) -> a, closeables);
"prometheus", CONFIG_PROPERTIES, spiHelper, (a, b) -> a, closeables);
cleanup.addCloseables(closeables);

assertThat(reader).isInstanceOf(PrometheusHttpServer.class);
Expand All @@ -60,7 +61,7 @@ void configureReader_PrometheusOnClasspath() {
void configureExporter_KnownSpiExportersOnClasspath(
String exporterName, Class<? extends Closeable> expectedExporter) {
NamedSpiManager<MetricExporter> spiExportersManager =
MetricExporterConfiguration.metricExporterSpiManager(EMPTY, spiHelper);
MetricExporterConfiguration.metricExporterSpiManager(CONFIG_PROPERTIES, spiHelper);

MetricExporter metricExporter =
MetricExporterConfiguration.configureExporter(exporterName, spiExportersManager);
Expand All @@ -81,7 +82,7 @@ private static Stream<Arguments> knownExporters() {
void configureMetricReader_KnownSpiExportersOnClasspath(
String exporterName, Class<? extends Closeable> expectedExporter) {
NamedSpiManager<MetricReader> spiMetricReadersManager =
MetricExporterConfiguration.metricReadersSpiManager(EMPTY, spiHelper);
MetricExporterConfiguration.metricReadersSpiManager(CONFIG_PROPERTIES, spiHelper);

MetricReader metricReader =
MetricExporterConfiguration.configureMetricReader(exporterName, spiMetricReadersManager);
Expand Down

0 comments on commit 533c30a

Please sign in to comment.