Search in sources :

Example 61 with Gauge

use of com.codahale.metrics.Gauge in project metrics by dropwizard.

the class MemoryUsageGaugeSetTest method hasAGaugeForNonHeapCommitted.

@Test
public void hasAGaugeForNonHeapCommitted() {
    final Gauge gauge = (Gauge) gauges.getMetrics().get("non-heap.committed");
    assertThat(gauge.getValue()).isEqualTo(1L);
}
Also used : Gauge(com.codahale.metrics.Gauge) Test(org.junit.Test)

Example 62 with Gauge

use of com.codahale.metrics.Gauge in project metrics by dropwizard.

the class CollectdReporterTest method reportsGauges.

private <T extends Number> void reportsGauges(T value) throws Exception {
    reporter.report(map("gauge", (Gauge) () -> value), map(), map(), map(), map());
    ValueList data = receiver.next();
    assertThat(data.getValues()).containsExactly(value.doubleValue());
}
Also used : ValueList(org.collectd.api.ValueList) Gauge(com.codahale.metrics.Gauge)

Example 63 with Gauge

use of com.codahale.metrics.Gauge in project verify-hub by alphagov.

the class IdpAssertionMetricsCollectorTest method shouldCollectNotOnOrAfterValueFromAssertion.

@Test
public void shouldCollectNotOnOrAfterValueFromAssertion() {
    DateTimeFreezer.freezeTime();
    MetricRegistry metricRegistry = new MetricRegistry();
    IdpAssertionMetricsCollector idpAssertionMetricsCollector = new IdpAssertionMetricsCollector(metricRegistry);
    DateTime notOnOrAfter = DateTime.now().plusMinutes(15);
    Assertion anAssertion = anAssertion().withIssuer(anIssuer().withIssuerId("testIdP").build()).withSubject(aSubject().withSubjectConfirmation(aSubjectConfirmation().withSubjectConfirmationData(aSubjectConfirmationData().withNotOnOrAfter(notOnOrAfter).build()).build()).build()).buildUnencrypted();
    idpAssertionMetricsCollector.update(anAssertion);
    Gauge actual = metricRegistry.getGauges().get("notOnOrAfter.testIdP");
    assertThat(actual.getValue()).isEqualTo(15L);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) DateTime(org.joda.time.DateTime) Gauge(com.codahale.metrics.Gauge) Test(org.junit.Test)

Example 64 with Gauge

use of com.codahale.metrics.Gauge in project verify-hub by alphagov.

the class IdpAssertionMetricsCollectorTest method shouldNotRegisterIdpAlreadyExist.

@Test
public void shouldNotRegisterIdpAlreadyExist() {
    MetricRegistry metricRegistry = mock(MetricRegistry.class);
    SortedMap<String, Gauge> gaugeMock = mock(SortedMap.class);
    when(gaugeMock.containsKey(any())).thenReturn(true);
    when(metricRegistry.getGauges()).thenReturn(gaugeMock);
    Assertion assertion = anAssertion().withIssuer(anIssuer().withIssuerId("testIdP").build()).buildUnencrypted();
    IdpAssertionMetricsCollector idpAssertionMetricsCollector = new IdpAssertionMetricsCollector(metricRegistry);
    idpAssertionMetricsCollector.update(assertion);
    verify(metricRegistry, times(0)).register(any(), any());
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) Gauge(com.codahale.metrics.Gauge) Test(org.junit.Test)

Aggregations

Gauge (com.codahale.metrics.Gauge)64 Test (org.junit.Test)43 Counter (com.codahale.metrics.Counter)10 MetricRegistry (com.codahale.metrics.MetricRegistry)9 Meter (com.codahale.metrics.Meter)8 Metric (com.codahale.metrics.Metric)8 Timer (com.codahale.metrics.Timer)7 SortedMap (java.util.SortedMap)7 Histogram (com.codahale.metrics.Histogram)6 Map (java.util.Map)6 Matchers.anyString (org.mockito.Matchers.anyString)3 Snapshot (com.codahale.metrics.Snapshot)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 Semaphore (java.util.concurrent.Semaphore)2 SolrMetricManager (org.apache.solr.metrics.SolrMetricManager)2 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)2 ValueList (org.collectd.api.ValueList)2 Assertion (org.opensaml.saml.saml2.core.Assertion)2