Search in sources :

Example 6 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class JsonExporterGetTest method multipeRepositoriesAreGroupedByNameMetricOption.

@Test
public void multipeRepositoriesAreGroupedByNameMetricOption() {
    exporter = exporter.in(Type.BASE);
    Gauge<Long> fooVal = () -> 1L;
    MetricID fooValID = new MetricID("fooVal", new Tag("store", "webshop"));
    export(fooValID, fooVal);
    exporter = exporter.in(Type.APPLICATION);
    export(fooValID, fooVal);
    assertOutputEquals("\n" + "{\n" + "    \"base\": {\n" + "        \"fooVal;store=webshop\": 1\n" + "    },\n" + "    \"application\": {\n" + "        \"fooVal;store=webshop\": 1\n" + "    }\n" + "}");
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) Tag(org.eclipse.microprofile.metrics.Tag) Test(org.junit.Test)

Example 7 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class JsonExporterGetTest method exportConcurrentGauge.

@Test
public void exportConcurrentGauge() {
    ConcurrentGauge callCount = mock(ConcurrentGauge.class);
    when(callCount.getCount()).thenReturn(48L);
    when(callCount.getMin()).thenReturn(4L);
    when(callCount.getMax()).thenReturn(50L);
    ConcurrentGauge callCount2 = mock(ConcurrentGauge.class);
    when(callCount2.getCount()).thenReturn(23L);
    when(callCount2.getMin()).thenReturn(1L);
    when(callCount2.getMax()).thenReturn(29L);
    export(new MetricID("callCount"), callCount);
    export(new MetricID("callCount", new Tag("component", "backend")), callCount2);
    assertOutputEqualsFile("ConcurrentGauge.json");
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) ConcurrentGauge(org.eclipse.microprofile.metrics.ConcurrentGauge) Tag(org.eclipse.microprofile.metrics.Tag) Test(org.junit.Test)

Example 8 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class JsonExporterGetTest method gaugesThatThrowIllegalStateExceptionWhenReadAreNotExported.

@Test
public void gaugesThatThrowIllegalStateExceptionWhenReadAreNotExported() {
    Gauge<Long> gauge = () -> {
        throw new IllegalStateException("test");
    };
    MetricID metricID = new MetricID("test4");
    Metadata metadata = Metadata.builder().withName(metricID.getName()).build();
    assertOutputEquals("\n{\n}", metricID, gauge, metadata);
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) Metadata(org.eclipse.microprofile.metrics.Metadata) Test(org.junit.Test)

Example 9 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class JsonExporterGetTest method exportMeter.

@Test
public void exportMeter() {
    Meter requests = mock(Meter.class);
    when(requests.getCount()).thenReturn(29382L);
    when(requests.getMeanRate()).thenReturn(12.223d);
    when(requests.getOneMinuteRate()).thenReturn(12.563d);
    when(requests.getFiveMinuteRate()).thenReturn(12.364d);
    when(requests.getFifteenMinuteRate()).thenReturn(12.126d);
    // example uses same values for all three meters so we can get away with just one
    // but conceptually those should be three different meter instances
    export(new MetricID("requests"), requests);
    export(new MetricID("requests", new Tag("servlet", "one")), requests);
    export(new MetricID("requests", new Tag("servlet", "two")), requests);
    assertOutputEqualsFile("Meter.json");
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) Meter(org.eclipse.microprofile.metrics.Meter) Tag(org.eclipse.microprofile.metrics.Tag) Test(org.junit.Test)

Example 10 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class JsonExporterGetTest method gaugesWithNonNumberValuesAreNotExported.

/*
     * Below tests are no examples from the specification
     */
@Test
public void gaugesWithNonNumberValuesAreNotExported() {
    Gauge<String> gauge = () -> "hello world";
    MetricID metricID = new MetricID("test3");
    Metadata metadata = Metadata.builder().withName(metricID.getName()).build();
    assertOutputEquals("\n{\n}", metricID, gauge, metadata);
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) Metadata(org.eclipse.microprofile.metrics.Metadata) Test(org.junit.Test)

Aggregations

MetricID (org.eclipse.microprofile.metrics.MetricID)53 Test (org.junit.Test)41 Metadata (org.eclipse.microprofile.metrics.Metadata)31 Tag (org.eclipse.microprofile.metrics.Tag)25 Counter (org.eclipse.microprofile.metrics.Counter)10 Metric (org.eclipse.microprofile.metrics.Metric)6 SimpleTimer (org.eclipse.microprofile.metrics.SimpleTimer)6 Snapshot (org.eclipse.microprofile.metrics.Snapshot)6 Histogram (org.eclipse.microprofile.metrics.Histogram)5 ConcurrentGauge (org.eclipse.microprofile.metrics.ConcurrentGauge)4 Timer (org.eclipse.microprofile.metrics.Timer)4 Gauge (org.eclipse.microprofile.metrics.Gauge)3 MonitoringDataCollector (fish.payara.monitoring.collect.MonitoringDataCollector)2 ArrayList (java.util.ArrayList)2 Meter (org.eclipse.microprofile.metrics.Meter)2 NoSuchRegistryException (fish.payara.microprofile.metrics.exception.NoSuchRegistryException)1 TimerImpl (fish.payara.microprofile.metrics.impl.TimerImpl)1 MBeanMetadata (fish.payara.microprofile.metrics.jmx.MBeanMetadata)1 FileNotFoundException (java.io.FileNotFoundException)1 Collections.emptyMap (java.util.Collections.emptyMap)1