-
Notifications
You must be signed in to change notification settings - Fork 834
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
Conversation
Codecov ReportAll modified lines are covered by tests ✅ 📢 Thoughts on this report? Let us know!. |
How does the config/port=0 change address the timing? Or does that just change how the binding happens to bypass the conflict entirely? |
port 0 means bind to any free port |
Got it. Was just surprised that your discussion didn't actually mention the approach of the fix. 🙃 |
@@ -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); |
There was a problem hiding this comment.
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.
Resolves #5866
My guess is that
configureMetricReader_KnownSpiExportersOnClasspath
fails withjava.net.BindException: Address already in use
becauseconfigureReader_PrometheusOnClasspath
, which is the only test that also startsPrometheusHttpServer
inMetricExporterConfigurationTest
had not yet shut downPrometheusHttpServer
. Shutting downPrometheusHttpServer
opentelemetry-java/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServer.java
Line 164 in 5ccc7fc
configureReader_PrometheusOnClasspath
is 10.104s. So it think it is plausible thatconfigureMetricReader_KnownSpiExportersOnClasspath
started beforePrometheusHttpServer
from previous test was shut down. Also there is a 10s wait in shutting down ofPrometheusHttpServer
opentelemetry-java/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServer.java
Lines 144 to 160 in 5ccc7fc