mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 09:27:16 +02:00
Remove old json logging from flows
This was meant for log replay and has long been ignored/useless. As part of this, remove execution time from EppResponse since this was the only thing consuming it. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137293734
This commit is contained in:
parent
5f8a95d853
commit
198558901d
7 changed files with 20 additions and 103 deletions
|
@ -101,39 +101,24 @@ public class FlowRunner {
|
|||
metric.incrementAttempts();
|
||||
return createAndInitFlow(clock.nowUtc()).run();
|
||||
}
|
||||
// We log the command in a structured format. Note that we do this before the transaction;
|
||||
// if we did it after, we might miss a transaction that committed successfully but then crashed
|
||||
// before it could log.
|
||||
logger.info("EPP_Mutation " + new JsonLogStatement(trid)
|
||||
.add("client", clientId)
|
||||
.add("privileges", isSuperuser ? "SUPERUSER" : "NORMAL")
|
||||
.add("xmlBytes", xmlBase64));
|
||||
try {
|
||||
EppOutput flowResult =
|
||||
ofy()
|
||||
.transact(
|
||||
new Work<EppOutput>() {
|
||||
@Override
|
||||
public EppOutput run() {
|
||||
metric.incrementAttempts();
|
||||
try {
|
||||
EppOutput output = createAndInitFlow(ofy().getTransactionTime()).run();
|
||||
if (isDryRun) {
|
||||
throw new DryRunException(output);
|
||||
}
|
||||
return output;
|
||||
} catch (EppException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
logger.info("EPP_Mutation_Committed " + new JsonLogStatement(trid)
|
||||
.add("executionTime", flowResult.getResponse().getExecutionTime().getMillis()));
|
||||
return flowResult;
|
||||
return ofy().transact(new Work<EppOutput>() {
|
||||
@Override
|
||||
public EppOutput run() {
|
||||
metric.incrementAttempts();
|
||||
try {
|
||||
EppOutput output = createAndInitFlow(ofy().getTransactionTime()).run();
|
||||
if (isDryRun) {
|
||||
throw new DryRunException(output);
|
||||
}
|
||||
return output;
|
||||
} catch (EppException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}});
|
||||
} catch (DryRunException e) {
|
||||
return e.output;
|
||||
} catch (RuntimeException e) {
|
||||
logger.warning("EPP_Mutation_Failed " + new JsonLogStatement(trid));
|
||||
logger.warning(getStackTraceAsString(e));
|
||||
if (e.getCause() instanceof EppException) {
|
||||
throw (EppException) e.getCause();
|
||||
|
@ -151,43 +136,6 @@ public class FlowRunner {
|
|||
isSuperuser,
|
||||
now);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for logging in json format.
|
||||
*
|
||||
* <p>This is needed because the usual json outputters perform normalizations that we don't want
|
||||
* or need, since we know that our values never need to be escaped - there are only strings and
|
||||
* numbers, and the strings are not allowed to contain quote characters.
|
||||
*
|
||||
* <p>An example output for an EPP_Mutation: {"trid":"abc-123", "client":"some_registrar",
|
||||
* "tld":"com", "xmlBytes":"abc123DEF"}
|
||||
*
|
||||
* <p>An example output for an EPP_Mutation_Committed that doesn't create a new resource:
|
||||
* {"trid":"abc-123", "executionTime":123456789}
|
||||
*/
|
||||
private static class JsonLogStatement {
|
||||
|
||||
StringBuilder message;
|
||||
|
||||
JsonLogStatement(Trid trid) {
|
||||
message =
|
||||
new StringBuilder("{\"trid\":\"").append(trid.getServerTransactionId()).append('\"');
|
||||
}
|
||||
|
||||
JsonLogStatement add(String key, Object value) {
|
||||
if (value != null) {
|
||||
String quote = value instanceof String ? "\"" : "";
|
||||
message.append(String.format(", \"%s\":%s%s%s", key, quote, value, quote));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return message + "}";
|
||||
}
|
||||
}
|
||||
|
||||
/** Exception for canceling a transaction while capturing what the output would have been. */
|
||||
private static class DryRunException extends RuntimeException {
|
||||
final EppOutput output;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue