use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class MetricRegistryImplTest method counterByMetadataReceivesExistingCounter.
@Test
public void counterByMetadataReceivesExistingCounter() {
String name = nextName();
Metadata metadata = withNameAnd(name).withType(MetricType.COUNTER).build();
Counter counter = registry.counter(metadata);
assertSame(counter, registry.counter(metadata));
assertNotSame(counter, registry.counter(metadata, SOME_TAG));
}
use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class MetricRegistryImplTest method counterByMetadataCreatesNonExistingCounter.
@Test
public void counterByMetadataCreatesNonExistingCounter() {
String name = nextName();
Metadata metadata = withNameAnd(name).withType(MetricType.COUNTER).build();
Counter counter = registry.counter(metadata);
assertNotNull(counter);
Metadata actualMetadata = registry.getMetadata(name);
assertEquals(name, actualMetadata.getName());
assertEquals(MetricType.COUNTER, actualMetadata.getTypeRaw());
assertEquals(metadata, actualMetadata);
}
use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class MetricRegistryImplTest method counterByNameCreatesNonExistingCounter.
@Test
public void counterByNameCreatesNonExistingCounter() {
String name = nextName();
Counter counter = registry.counter(name);
assertNotNull(counter);
Metadata metadata = registry.getMetadata(name);
assertEquals(name, metadata.getName());
assertEquals(name, metadata.getDisplayName());
assertEquals(MetricType.COUNTER, metadata.getTypeRaw());
}
use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class JsonExporterOptionsTest method gaugesThatThrowIllegalStateExceptionWhenReadDoExportMetadata.
@Test
public void gaugesThatThrowIllegalStateExceptionWhenReadDoExportMetadata() {
Gauge<Long> gauge = () -> {
throw new IllegalStateException("test");
};
MetricID metricID = new MetricID("test4");
Metadata metadata = Metadata.builder().withName(metricID.getName()).withType(MetricType.GAUGE).build();
assertOutputEquals("\n" + "{\n" + " \"test4\": {\n" + " \"unit\": \"none\",\n" + " \"type\": \"gauge\"\n" + " }\n" + "}", metricID, gauge, metadata);
}
use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class JsonExporterOptionsTest method multipleMetricOptionsAreGroupedByName.
@Test
public void multipleMetricOptionsAreGroupedByName() {
Gauge<Long> fooVal = () -> 1L;
MetricID fooValID = new MetricID("fooVal", new Tag("store", "webshop"));
Metadata fooValMeta = Metadata.builder().withName("fooVal").withDescription("The average duration of foo requests during last 5 minutes").withUnit(MetricUnits.MILLISECONDS).withDisplayName("Duration of foo").withType(MetricType.GAUGE).build();
Gauge<Long> barVal1 = () -> 2L;
Gauge<Long> barVal2 = () -> 3L;
MetricID barValID1 = new MetricID("barVal", new Tag("store", "webshop"), new Tag("component", "backend"));
MetricID barValID2 = new MetricID("barVal", new Tag("store", "webshop"), new Tag("component", "frontend"));
Metadata barValMeta = Metadata.builder().withName("barVal").withUnit(MetricUnits.MEGABYTES).withType(MetricType.GAUGE).build();
export(fooValID, fooVal, fooValMeta);
export(barValID1, barVal1, barValMeta);
export(barValID2, barVal2, barValMeta);
assertOutputEqualsFile("Options2.json");
}
Aggregations