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:
mcilwain 2017-05-24 10:00:14 -07:00 committed by Ben McIlwain
parent 1adeb57fea
commit bb67841884
14 changed files with 671 additions and 154 deletions

View file

@ -39,7 +39,7 @@ import org.joda.time.Instant;
* <p>The {@link MutableDistribution} values tracked by this metric can be reset with {@link
* EventMetric#reset()}.
*/
public final class EventMetric extends AbstractMetric<Distribution> {
public class EventMetric extends AbstractMetric<Distribution> {
/**
* Default {@link DistributionFitter} suitable for latency measurements.
@ -86,7 +86,7 @@ public final class EventMetric extends AbstractMetric<Distribution> {
}
@VisibleForTesting
final ImmutableList<MetricPoint<Distribution>> getTimestampedValues(Instant endTimestamp) {
ImmutableList<MetricPoint<Distribution>> getTimestampedValues(Instant endTimestamp) {
ImmutableList.Builder<MetricPoint<Distribution>> timestampedValues =
new ImmutableList.Builder<>();
@ -125,7 +125,7 @@ public final class EventMetric extends AbstractMetric<Distribution> {
*
* <p>The count of {@code labelValues} must be equal to the underlying metric's count of labels.
*/
public final void record(double sample, String... labelValues) {
public void record(double sample, String... labelValues) {
MetricsUtils.checkLabelValuesLength(this, labelValues);
recordMultiple(sample, 1, Instant.now(), ImmutableList.copyOf(labelValues));
@ -140,14 +140,14 @@ public final class EventMetric extends AbstractMetric<Distribution> {
*
* <p>The count of {@code labelValues} must be equal to the underlying metric's count of labels.
*/
public final void record(double sample, int count, String... labelValues) {
public void record(double sample, int count, String... labelValues) {
MetricsUtils.checkLabelValuesLength(this, labelValues);
recordMultiple(sample, count, Instant.now(), ImmutableList.copyOf(labelValues));
}
@VisibleForTesting
final void recordMultiple(
void recordMultiple(
double sample, int count, Instant startTimestamp, ImmutableList<String> labelValues) {
Lock lock = valueLocks.get(labelValues);
lock.lock();