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

record operationOutcome in MDC (DAT-16857) #5702

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import liquibase.logging.mdc.MdcKey;
import liquibase.logging.mdc.MdcManager;
import liquibase.logging.mdc.MdcObject;
import liquibase.logging.mdc.MdcValue;
import liquibase.logging.mdc.customobjects.ExceptionDetails;
import liquibase.util.LiquibaseUtil;
import liquibase.util.StringUtil;
Expand Down Expand Up @@ -218,6 +219,7 @@ public CommandResults execute() throws CommandExecutionException {
} catch (Exception runException) {
// Suppress the exception for now so that we can run the cleanup steps even when encountering an exception.
thrownException = Optional.of(runException);
Scope.getCurrentScope().addMdcValue(MdcKey.OPERATION_OUTCOME, MdcValue.COMMAND_FAILED, false);
break;
}
executedCommands.add(command);
Expand Down Expand Up @@ -245,6 +247,8 @@ public CommandResults execute() throws CommandExecutionException {
logPrimaryExceptionToMdc(thrownException.get(), source);
}
throw thrownException.get();
} else {
Scope.getCurrentScope().addMdcValue(MdcKey.OPERATION_OUTCOME, MdcValue.COMMAND_SUCCESSFUL, false);
}
} catch (Exception e) {
if (e instanceof CommandExecutionException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ public class MdcKey {
public static final String PRIMARY_EXCEPTION_SOURCE = "primaryExceptionSource";
public static final String QUALITY_CHECKS = "qualityChecks";
public static final String DUPLICATE_CHANGESETS = "duplicateChangesets";
public static final String OPERATION_OUTCOME = "operationOutcome";
}