Add method to create and register EventMetrics

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132346375
This commit is contained in:
shikhman 2016-09-06 11:58:46 -07:00 committed by Ben McIlwain
parent 2ba9b01a13
commit 0538c1e210
3 changed files with 65 additions and 0 deletions

View file

@ -138,6 +138,29 @@ public class MetricRegistryImplTest {
ImmutableSet.of(label)));
}
@Test
public void testNewEventMetric_createsEventMetric() {
DistributionFitter fitter = CustomFitter.create(ImmutableSet.of(0.0));
EventMetric testMetric =
MetricRegistryImpl.getDefault()
.newEventMetric(
"/test_metric",
"test_description",
"test_valuedisplayname",
ImmutableSet.of(label),
fitter);
assertThat(testMetric.getValueClass()).isSameAs(Distribution.class);
assertThat(testMetric.getMetricSchema())
.isEqualTo(
MetricSchema.create(
"/test_metric",
"test_description",
"test_valuedisplayname",
Kind.CUMULATIVE,
ImmutableSet.of(label)));
}
@Test
public void testRegister_duplicateMetric_throwsException() {
SettableMetric<Boolean> testMetric =