mirror of
https://github.com/google/nomulus
synced 2026-01-05 04:56:03 +00:00
Force endTimestamp to be strictly greater than or equal to startTimestamp
This fixes an error that we've been seeing from Stackdriver. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=132358790
This commit is contained in:
@@ -21,6 +21,7 @@ import static google.registry.monitoring.metrics.MetricsUtils.newConcurrentHashM
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.util.concurrent.AtomicLongMap;
|
||||
import com.google.common.util.concurrent.Striped;
|
||||
import google.registry.monitoring.metrics.MetricSchema.Kind;
|
||||
@@ -131,6 +132,12 @@ public final class Counter extends AbstractMetric<Long>
|
||||
valueLocks.get(labelValues).unlock();
|
||||
}
|
||||
|
||||
// There is an opportunity for endTimestamp to be less than startTimestamp if
|
||||
// one of the modification methods is called on a value before the lock for that value is
|
||||
// acquired but after getTimestampedValues has been invoked. Just set endTimestamp equal to
|
||||
// startTimestamp if that happens.
|
||||
endTimestamp = Ordering.natural().max(startTimestamp, endTimestamp);
|
||||
|
||||
timestampedValues.add(
|
||||
MetricPoint.create(this, labelValues, startTimestamp, endTimestamp, entry.getValue()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user