mirror of
https://github.com/google/nomulus.git
synced 2025-08-12 04:29:39 +02:00
Refactor EppMetrics into the EppMetric value type
This change refactors EppMetrics from the mutable self-exporting thing that it was into a real value type EppMetric, and delegates exporting functionality to the BigQueryMetricsEnqueuer. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=132387660
This commit is contained in:
parent
b77ebd1df9
commit
42a39b0ddc
16 changed files with 484 additions and 234 deletions
|
@ -31,7 +31,7 @@ import google.registry.flows.FlowModule.Transactional;
|
|||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.monitoring.whitebox.EppMetrics;
|
||||
import google.registry.monitoring.whitebox.EppMetric;
|
||||
import google.registry.util.Clock;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -67,7 +67,7 @@ public class FlowRunner {
|
|||
@Inject @DryRun boolean isDryRun;
|
||||
@Inject @Superuser boolean isSuperuser;
|
||||
@Inject @Transactional boolean isTransactional;
|
||||
@Inject EppMetrics metrics;
|
||||
@Inject EppMetric.Builder metric;
|
||||
@Inject SessionMetadata sessionMetadata;
|
||||
@Inject Trid trid;
|
||||
@Inject FlowRunner() {}
|
||||
|
@ -100,7 +100,7 @@ public class FlowRunner {
|
|||
"xml", prettyXml,
|
||||
"xmlBytes", xmlBase64)));
|
||||
if (!isTransactional) {
|
||||
metrics.incrementAttempts();
|
||||
metric.incrementAttempts();
|
||||
return createAndInitFlow(clock.nowUtc()).run();
|
||||
}
|
||||
// We log the command in a structured format. Note that we do this before the transaction;
|
||||
|
@ -111,20 +111,24 @@ public class FlowRunner {
|
|||
.add("privileges", isSuperuser ? "SUPERUSER" : "NORMAL")
|
||||
.add("xmlBytes", xmlBase64));
|
||||
try {
|
||||
EppOutput flowResult = ofy().transact(new Work<EppOutput>() {
|
||||
@Override
|
||||
public EppOutput run() {
|
||||
metrics.incrementAttempts();
|
||||
try {
|
||||
EppOutput output = createAndInitFlow(ofy().getTransactionTime()).run();
|
||||
if (isDryRun) {
|
||||
throw new DryRunException(output);
|
||||
}
|
||||
return output;
|
||||
} catch (EppException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}});
|
||||
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("createdRepoId", flowResult.getResponse().getCreatedRepoId())
|
||||
.add("executionTime", flowResult.getResponse().getExecutionTime().getMillis()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue