mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Change to metrics to keep track of when the metric value was first set
This CL also adds IncrementableMetric#reset() methods to allow resetting the value and start timestamp of IncrementableMetrics. This is necessary because some backends, like Stackdriver, use non-monotonic changes in cumulative metric values to detect timeseries restarts. Tracking and re-setting the start timestamp allows users to track mostly monotonic metrics which may have non-monotonic discontinuities. See https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries#Point for more details. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130795229
This commit is contained in:
parent
b6eaba08eb
commit
91f8b6da38
7 changed files with 192 additions and 26 deletions
|
@ -29,6 +29,10 @@ import org.joda.time.Instant;
|
|||
*
|
||||
* <p>This pattern works well for gauge-like metrics, such as CPU usage, memory usage, and file
|
||||
* descriptor counts.
|
||||
*
|
||||
* <p>The {@link MetricPoint#interval()} of values of instances of this metric will always have a
|
||||
* start time equal to the end time, since the metric value represents a point-in-time snapshot with
|
||||
* no relationship to prior values.
|
||||
*/
|
||||
@ThreadSafe
|
||||
public final class VirtualMetric<V> extends AbstractMetric<V> {
|
||||
|
@ -77,7 +81,8 @@ public final class VirtualMetric<V> extends AbstractMetric<V> {
|
|||
|
||||
ImmutableList.Builder<MetricPoint<V>> metricPoints = ImmutableList.builder();
|
||||
for (Entry<ImmutableList<String>, V> entry : values.entrySet()) {
|
||||
metricPoints.add(MetricPoint.create(this, entry.getKey(), timestamp, entry.getValue()));
|
||||
metricPoints.add(
|
||||
MetricPoint.create(this, entry.getKey(), timestamp, timestamp, entry.getValue()));
|
||||
}
|
||||
|
||||
cardinality = values.size();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue