diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java index 02c8e2b2908..b1178d3081c 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java @@ -424,6 +424,7 @@ private Future accountFallback(Throwable exception, if (exception instanceof PreBidException) { UNKNOWN_ACCOUNT_LOGGER.warn(accountErrorMessage(exception.getMessage(), httpRequest), 100); } else { + metrics.updateAccountRequestRejectedByFailedFetch(accountId); logger.warn("Error occurred while fetching account: {0}", exception.getMessage()); logger.debug("Error occurred while fetching account", exception); } diff --git a/src/main/java/org/prebid/server/metric/MetricName.java b/src/main/java/org/prebid/server/metric/MetricName.java index f3450b5f4d4..ca51fe09b73 100644 --- a/src/main/java/org/prebid/server/metric/MetricName.java +++ b/src/main/java/org/prebid/server/metric/MetricName.java @@ -119,6 +119,7 @@ public enum MetricName { rejected_by_invalid_account("rejected.invalid-account"), rejected_by_invalid_stored_impr("rejected.invalid-stored-impr"), rejected_by_invalid_stored_request("rejected.invalid-stored-request"), + rejected_by_account_fetch_failed("rejected.account-fetch-failed"), // currency rates stale, diff --git a/src/main/java/org/prebid/server/metric/Metrics.java b/src/main/java/org/prebid/server/metric/Metrics.java index 52952734938..aa5316235b5 100644 --- a/src/main/java/org/prebid/server/metric/Metrics.java +++ b/src/main/java/org/prebid/server/metric/Metrics.java @@ -258,6 +258,10 @@ public void updateAccountRequestRejectedByInvalidStoredRequestMetrics(String acc updateAccountRequestsMetrics(accountId, MetricName.rejected_by_invalid_stored_request); } + public void updateAccountRequestRejectedByFailedFetch(String accountId) { + updateAccountRequestsMetrics(accountId, MetricName.rejected_by_account_fetch_failed); + } + private void updateAccountRequestsMetrics(String accountId, MetricName metricName) { forAccount(accountId).requests().incCounter(metricName); } diff --git a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java index c7daf3e74c8..a65a86cd29a 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java @@ -553,6 +553,7 @@ public void fetchAccountShouldReturnEmptyAccountIfExceptionOccurred() { AuctionContext.builder().bidRequest(bidRequest).build()); // then + verify(metrics).updateAccountRequestRejectedByFailedFetch(accountId); verify(applicationSettings).getAccountById(eq(accountId), any()); assertThat(result.result()).isEqualTo(Account.empty(accountId)); diff --git a/src/test/java/org/prebid/server/metric/MetricsTest.java b/src/test/java/org/prebid/server/metric/MetricsTest.java index df74259945d..8a6518666d5 100644 --- a/src/test/java/org/prebid/server/metric/MetricsTest.java +++ b/src/test/java/org/prebid/server/metric/MetricsTest.java @@ -1411,6 +1411,16 @@ public void shouldIncrementUpdateAccountActivityProcessedRulesCount() { .isEqualTo(1); } + @Test + public void shouldIncrementUpdateAccountRequestRejectedByFailedFetchCount() { + // when + metrics.updateAccountRequestRejectedByFailedFetch("account_id"); + + // then + assertThat(metricRegistry.counter("account.account_id.requests.rejected.account-fetch-failed").getCount()) + .isEqualTo(1); + } + private void verifyCreatesConfiguredCounterType(Consumer metricsConsumer) { final EnumMap> counterTypeClasses = new EnumMap<>(CounterType.class); counterTypeClasses.put(CounterType.counter, Counter.class);