mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Add Truth subjects for incrementable and event metrics
This CL adds Truth framework subjects to some metrics in the Stackdriver metrics library, in a contrib subpackage. It doesn't deal with gauge metrics, and for event metrics, the assertions can only be that a metric has or does not have a distribution for a particular set of label values. Asserting more fine-grained propositions regarding the distribution will require a distribution subject. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=149112692
This commit is contained in:
parent
5614760d53
commit
9a15f08b3a
1 changed files with 14 additions and 1 deletions
|
@ -25,7 +25,7 @@ import org.joda.time.Interval;
|
|||
* time {@link Interval}.
|
||||
*/
|
||||
@AutoValue
|
||||
public abstract class MetricPoint<V> {
|
||||
public abstract class MetricPoint<V> implements Comparable<MetricPoint<V>> {
|
||||
|
||||
/**
|
||||
* Returns a new {@link MetricPoint} representing a value at a specific {@link Instant}.
|
||||
|
@ -69,4 +69,17 @@ public abstract class MetricPoint<V> {
|
|||
public abstract Interval interval();
|
||||
|
||||
public abstract V value();
|
||||
|
||||
@Override
|
||||
public int compareTo(MetricPoint<V> other) {
|
||||
int minLength = Math.min(this.labelValues().size(), other.labelValues().size());
|
||||
for (int index = 0; index < minLength; index++) {
|
||||
int comparisonResult =
|
||||
this.labelValues().get(index).compareTo(other.labelValues().get(index));
|
||||
if (comparisonResult != 0) {
|
||||
return comparisonResult;
|
||||
}
|
||||
}
|
||||
return Integer.compare(this.labelValues().size(), other.labelValues().size());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue