mirror of
https://github.com/google/nomulus.git
synced 2025-08-06 01:35:17 +02:00
Add metrics for async batch operation processing
We want to know how long it's actually taking to process asynchronous contact/host deletions and DNS refreshes on host renames. This adds instrumentation. Five metrics are recorded as follows: * An incrementable metric for each async task processed (split out by type of task and result). * Two event metrics for processing time between when a task is enqueued and when it is processed -- tracked separately for contact/host deletion and DNS refresh on host rename. * Two event metrics for batch size every time the two mapreduces are run (this is usually 0). Tracked separately for contact/host deletion and DNS refresh on host rename. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=157001310
This commit is contained in:
parent
1adeb57fea
commit
bb67841884
14 changed files with 671 additions and 154 deletions
|
@ -28,6 +28,7 @@ java_library(
|
|||
"//java/google/registry/dns",
|
||||
"//java/google/registry/flows",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/monitoring/metrics",
|
||||
"//java/google/registry/monitoring/whitebox",
|
||||
"//java/google/registry/pricing",
|
||||
"//java/google/registry/request",
|
||||
|
|
|
@ -156,7 +156,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
|||
}
|
||||
|
||||
/** Asserts the presence of a single enqueued async contact or host deletion */
|
||||
protected static <T extends EppResource> void assertAsyncDeletionTaskEnqueued(
|
||||
protected <T extends EppResource> void assertAsyncDeletionTaskEnqueued(
|
||||
T resource, String requestingClientId, Trid trid, boolean isSuperuser) throws Exception {
|
||||
assertTasksEnqueued(
|
||||
"async-delete-pull",
|
||||
|
@ -166,7 +166,8 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
|||
.param("requestingClientId", requestingClientId)
|
||||
.param("clientTransactionId", trid.getClientTransactionId())
|
||||
.param("serverTransactionId", trid.getServerTransactionId())
|
||||
.param("isSuperuser", Boolean.toString(isSuperuser)));
|
||||
.param("isSuperuser", Boolean.toString(isSuperuser))
|
||||
.param("requestedTime", clock.nowUtc().toString()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.flows.async;
|
||||
|
||||
import static google.registry.flows.async.AsyncFlowMetrics.OperationResult.SUCCESS;
|
||||
import static google.registry.flows.async.AsyncFlowMetrics.OperationType.CONTACT_AND_HOST_DELETE;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
import google.registry.monitoring.metrics.EventMetric;
|
||||
import google.registry.monitoring.metrics.IncrementableMetric;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectRule;
|
||||
import google.registry.testing.ShardableTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link AsyncFlowMetrics}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class AsyncFlowMetricsTest extends ShardableTestCase {
|
||||
|
||||
@Rule public final InjectRule inject = new InjectRule();
|
||||
|
||||
private final IncrementableMetric asyncFlowOperationCounts = mock(IncrementableMetric.class);
|
||||
private final EventMetric asyncFlowOperationProcessingTime = mock(EventMetric.class);
|
||||
private final EventMetric asyncFlowBatchSize = mock(EventMetric.class);
|
||||
private AsyncFlowMetrics asyncFlowMetrics;
|
||||
private FakeClock clock;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
clock = new FakeClock();
|
||||
asyncFlowMetrics = new AsyncFlowMetrics(clock);
|
||||
inject.setStaticField(
|
||||
AsyncFlowMetrics.class, "asyncFlowOperationCounts", asyncFlowOperationCounts);
|
||||
inject.setStaticField(
|
||||
AsyncFlowMetrics.class,
|
||||
"asyncFlowOperationProcessingTime",
|
||||
asyncFlowOperationProcessingTime);
|
||||
inject.setStaticField(AsyncFlowMetrics.class, "asyncFlowBatchSize", asyncFlowBatchSize);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecordAsyncFlowResult_calculatesDurationMillisCorrectly() {
|
||||
asyncFlowMetrics.recordAsyncFlowResult(
|
||||
CONTACT_AND_HOST_DELETE,
|
||||
SUCCESS,
|
||||
clock.nowUtc().minusMinutes(10).minusSeconds(5).minusMillis(566));
|
||||
verify(asyncFlowOperationCounts).increment("contactAndHostDelete", "success");
|
||||
verify(asyncFlowOperationProcessingTime).record(605566.0, "contactAndHostDelete", "success");
|
||||
verifyNoMoreInteractions(asyncFlowOperationCounts);
|
||||
verifyNoMoreInteractions(asyncFlowOperationProcessingTime);
|
||||
}
|
||||
}
|
|
@ -192,7 +192,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
// Task enqueued to change the NS record of the referencing domain via mapreduce.
|
||||
assertTasksEnqueued(
|
||||
QUEUE_ASYNC_HOST_RENAME,
|
||||
new TaskMatcher().param("hostKey", Key.create(renamedHost).getString()));
|
||||
new TaskMatcher()
|
||||
.param("hostKey", Key.create(renamedHost).getString())
|
||||
.param("requestedTime", clock.nowUtc().toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue