Skip to content
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

Fix flaky MetricExporterConfigurationTest #5877

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these tests cleanup their exporters / readers. This change will help make this test more resilient against other tests starting prometheus on the default port and not cleaning up, but best case we identify / fix the test failing to clean up.


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