Disable periodic metric reading in tests (#6025)

This commit is contained in:
Lauri Tulmin 2022-05-13 20:24:59 +03:00 committed by GitHub
parent 1df75378a1
commit c166c937b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -23,7 +23,9 @@ public class AgentTestingCustomizer implements AutoConfigurationCustomizerProvid
static final MetricReader metricReader =
PeriodicMetricReader.builder(AgentTestingExporterFactory.metricExporter)
.setInterval(Duration.ofMillis(100))
// Set really long interval. We'll call forceFlush when we need the metrics
// instead of collecting them periodically.
.setInterval(Duration.ofNanos(Long.MAX_VALUE))
.build();
static void reset() {

View File

@ -19,6 +19,7 @@ public class AgentTestingExporterFactory {
}
public static List<byte[]> getMetricExportRequests() {
AgentTestingCustomizer.metricReader.forceFlush().join(10, TimeUnit.SECONDS);
return metricExporter.getCollectedExportRequests();
}