// 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.monitoring.metrics.contrib; import static com.google.common.truth.Truth.assertAbout; import com.google.common.collect.BoundType; import com.google.common.collect.Range; import com.google.common.truth.FailureStrategy; import com.google.common.truth.SubjectFactory; import google.registry.monitoring.metrics.Distribution; import google.registry.monitoring.metrics.EventMetric; import google.registry.monitoring.metrics.MetricPoint; import java.util.Map; import javax.annotation.Nullable; /** * Truth subject for the {@link EventMetric} class. * *
For use with the Google Truth framework. Usage: * *
assertThat(myEventMetric) * .hasAnyValueForLabels("label1", "label2", "label3") * .and() * .hasNoOtherValues(); * assertThat(myEventMetric) * .doesNotHaveAnyValueForLabels("label1", "label2"); ** *
The assertions treat an empty distribution as no value at all. This is not how the data is
* actually stored; event metrics do in fact have an empty distribution after they are reset. But
* it's difficult to write assertions about expected metric data when any number of empty
* distributions can also be present, so they are screened out for convenience.
*/
public final class EventMetricSubject
extends AbstractMetricSubject