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

Additional metric for account fetch failed case #2792

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
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 @@ -424,6 +424,7 @@ private Future<Account> 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);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/prebid/server/metric/MetricName.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/prebid/server/metric/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/prebid/server/metric/MetricsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Metrics> metricsConsumer) {
final EnumMap<CounterType, Class<? extends Metric>> counterTypeClasses = new EnumMap<>(CounterType.class);
counterTypeClasses.put(CounterType.counter, Counter.class);
Expand Down
Loading