Skip to content

Commit

Permalink
feat(ebean): Add metric in ebean aspect DAO for failed tries, as well…
Browse files Browse the repository at this point in the history
… as failed operation… (#8576)

Co-authored-by: Indy Prentice <[email protected]>
  • Loading branch information
iprentic and Indy Prentice authored Aug 7, 2023
1 parent cf2750e commit d2efbba
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.linkedin.metadata.entity.ebean;

import com.codahale.metrics.MetricRegistry;
import com.datahub.util.exception.ModelConversionException;
import com.datahub.util.exception.RetryLimitReached;
import com.linkedin.common.AuditStamp;
Expand All @@ -14,6 +15,7 @@
import com.linkedin.metadata.query.ExtraInfoArray;
import com.linkedin.metadata.query.ListResultMetadata;
import com.linkedin.metadata.search.utils.QueryUtils;
import com.linkedin.metadata.utils.metrics.MetricUtils;
import io.ebean.DuplicateKeyException;
import io.ebean.EbeanServer;
import io.ebean.ExpressionList;
Expand Down Expand Up @@ -509,8 +511,10 @@ public <T> T runInTransactionWithRetry(@Nonnull final Supplier<T> block, final i
lastException = null;
break;
} catch (RollbackException | DuplicateKeyException exception) {
MetricUtils.counter(MetricRegistry.name(this.getClass(), "txFailed")).inc();
lastException = exception;
} catch (PersistenceException exception) {
MetricUtils.counter(MetricRegistry.name(this.getClass(), "txFailed")).inc();
// TODO: replace this logic by catching SerializableConflictException above once the exception is available
SpiServer pluginApi = _server.getPluginApi();
DatabasePlatform databasePlatform = pluginApi.getDatabasePlatform();
Expand Down Expand Up @@ -540,6 +544,7 @@ public <T> T runInTransactionWithRetry(@Nonnull final Supplier<T> block, final i
} while (++retryCount <= maxTransactionRetry);

if (lastException != null) {
MetricUtils.counter(MetricRegistry.name(this.getClass(), "txFailedAfterRetries")).inc();
throw new RetryLimitReached("Failed to add after " + maxTransactionRetry + " retries", lastException);
}

Expand Down

0 comments on commit d2efbba

Please sign in to comment.