Add optional logging for mismatches
This commit is contained in:
parent
aa65d34c36
commit
bacf524ae6
|
@ -20,6 +20,9 @@ public class DynamicAccountsDynamoDbMigrationConfiguration {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
boolean readEnabled;
|
boolean readEnabled;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
boolean logMismatches;
|
||||||
|
|
||||||
public boolean isBackgroundMigrationEnabled() {
|
public boolean isBackgroundMigrationEnabled() {
|
||||||
return backgroundMigrationEnabled;
|
return backgroundMigrationEnabled;
|
||||||
}
|
}
|
||||||
|
@ -52,4 +55,8 @@ public class DynamicAccountsDynamoDbMigrationConfiguration {
|
||||||
public boolean isReadEnabled() {
|
public boolean isReadEnabled() {
|
||||||
return readEnabled;
|
return readEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLogMismatches() {
|
||||||
|
return logMismatches;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -498,7 +498,7 @@ public class AccountsManager {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
final T dynamoResult = callable.call();
|
final T dynamoResult = callable.call();
|
||||||
compare(databaseResult, dynamoResult, mismatchClassifier, action);
|
compare(databaseResult, dynamoResult, mismatchClassifier, action, maybeUuid);
|
||||||
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
logger.error("Error running " + action + " in Dynamo", e);
|
logger.error("Error running " + action + " in Dynamo", e);
|
||||||
|
@ -507,16 +507,23 @@ public class AccountsManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void compare(final T databaseResult, final T dynamoResult, final BiFunction<T, T, Optional<String>> mismatchClassifier, final String action) {
|
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||||
|
private <T> void compare(final T databaseResult, final T dynamoResult, final BiFunction<T, T, Optional<String>> mismatchClassifier, final String action, final Optional<UUID> maybeUUid) {
|
||||||
|
|
||||||
DYNAMO_MIGRATION_COMPARISON_COUNTER.increment();
|
DYNAMO_MIGRATION_COMPARISON_COUNTER.increment();
|
||||||
|
|
||||||
mismatchClassifier.apply(databaseResult, dynamoResult)
|
mismatchClassifier.apply(databaseResult, dynamoResult)
|
||||||
.ifPresent(mismatchType ->
|
.ifPresent(mismatchType -> {
|
||||||
Metrics.counter(DYNAMO_MIGRATION_MISMATCH_COUNTER_NAME,
|
final String mismatchDescription = action + ":" + mismatchType;
|
||||||
"mismatchType", action + ":" + mismatchType)
|
Metrics.counter(DYNAMO_MIGRATION_MISMATCH_COUNTER_NAME,
|
||||||
.increment()
|
"mismatchType", mismatchDescription)
|
||||||
);
|
.increment();
|
||||||
|
|
||||||
|
if (maybeUUid.isPresent()
|
||||||
|
&& dynamicConfigurationManager.getConfiguration().getAccountsDynamoDbMigrationConfiguration().isLogMismatches()) {
|
||||||
|
logger.info("Mismatched {} for {}", mismatchDescription, maybeUUid.get());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static abstract class AccountComparisonMixin extends Account {
|
private static abstract class AccountComparisonMixin extends Account {
|
||||||
|
|
Loading…
Reference in New Issue