From 9c797fe13361c4d6cc978626153429c85c706c87 Mon Sep 17 00:00:00 2001 From: Anton Malinskiy Date: Sun, 13 Aug 2023 10:58:26 +1000 Subject: [PATCH] fix(core): warn about missing metrics only once --- .../analytics/external/MetricsProviderImpl.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/com/malinskiy/marathon/analytics/external/MetricsProviderImpl.kt b/core/src/main/kotlin/com/malinskiy/marathon/analytics/external/MetricsProviderImpl.kt index 6dedab40c..67b90846a 100644 --- a/core/src/main/kotlin/com/malinskiy/marathon/analytics/external/MetricsProviderImpl.kt +++ b/core/src/main/kotlin/com/malinskiy/marathon/analytics/external/MetricsProviderImpl.kt @@ -45,7 +45,10 @@ class MetricsProviderImpl(private val remoteDataStore: RemoteDataSource) : Metri val testName = test.toSafeTestName() return successRateMeasurements[key]?.get(testName) ?: { - logger.warn { "No success rate found for $testName. Using 0 i.e. fails all the time" } + if (!warningSuccessRateTimeReported.contains(testName)) { + logger.warn { "No success rate found for $testName. Using 0 i.e. fails all the time" } + warningSuccessRateTimeReported.add(testName) + } 0.0 }() } @@ -77,11 +80,17 @@ class MetricsProviderImpl(private val remoteDataStore: RemoteDataSource) : Metri } val testName = test.toSafeTestName() return executionTimeMeasurements[key]?.get(testName) ?: { - logger.warn { "No execution time found for $testName. Using 300_000 seconds i.e. long test" } + if (!warningExecutionTimeReported.contains(testName)) { + logger.warn { "No execution time found for $testName. Using 300_000 seconds i.e. long test" } + warningExecutionTimeReported.add(testName) + } 300_000.0 }() } + private val warningExecutionTimeReported = hashSetOf() + private val warningSuccessRateTimeReported = hashSetOf() + private fun fetchExecutionTime(percentile: Double, limit: Instant) = runBlocking { withRetry(3, RETRY_DELAY) { remoteDataStore.requestAllExecutionTimes(percentile, limit)