Package com.codahale.metrics

Examples of com.codahale.metrics.Counter


   
    @Test
    public void aCounterAnnotatedMethodWithDefaultNameAndMonotonic() throws Exception {
        instance.doYetAnotherThing();

        final Counter metric = registry.getCounters().get(name(InstrumentedWithCounter.class,
                                                                       "doYetAnotherThing", COUNTER_SUFFIX_MONOTONIC));

        assertThat("Guice creates a metric",
                   metric,
                   is(notNullValue()));

        // if things are working well then this should still be zero...
        assertThat("Guice creates a counter with the given value",
                   metric.getCount(),
                   is((long)0));
    }
View Full Code Here


    @Test
    public void aCounterAnnotatedMethodWithAbsoluteName() throws Exception {
        instance.doAThingWithAbsoluteName();

        final Counter metric = registry.getCounters().get(name("absoluteName"));

        assertThat("Guice creates a metric",
                   metric,
                   is(notNullValue()));

        assertThat("Guice creates a counter with the given value",
                   metric.getCount(),
                   is((long)1));
    }
View Full Code Here

        // By setting this up as a cache, if a counter doesn't exist when we try to retrieve it, it will automatically be created
        counters = CacheBuilder.newBuilder().build(
                new CacheLoader<String, Counter>() {
                    @Override
                    public Counter load(String key) throws Exception {
                        Counter counter = new Counter();
                        metricRegistry.register(key, counter);
                        return counter;
                    }
                }
        );
View Full Code Here

  public void testCompletelyEmpty() throws Exception {
    String str = "{}";
    Config config = ConfigFactory.parseString(str);
    MetricFilter filter = PatternMetricFilter.parse(new Configs(), config);
    assertSame(filter, MetricFilter.ALL);
    assertTrue(filter.matches("foo", new Counter()));
  }
View Full Code Here

  public void testEmpty() throws Exception {
    String str = "{ metricFilter : {} }";
    Config config = ConfigFactory.parseString(str);
    MetricFilter filter = PatternMetricFilter.parse(new Configs(), config);
    assertNotSame(filter, MetricFilter.ALL);
    assertTrue(filter.matches("foo", new Counter()));
    assertTrue(filter.toString().length() > 0);
  }
View Full Code Here

      "\n }}}";

    Config config = ConfigFactory.parseString(str);
    MetricFilter filter = PatternMetricFilter.parse(new Configs(), config);
    assertNotSame(filter, MetricFilter.ALL);
    assertTrue(filter.matches("foo", new Counter()));
    assertTrue(filter.matches("boo", new Counter()));
    assertFalse(filter.matches("foo.bar", new Counter()));
    assertFalse(filter.matches("boo", new Timer()));
    assertTrue(filter.toString().length() > 0);
  }
View Full Code Here

      "\n }}";

    Config config = ConfigFactory.parseString(str);
    MetricFilter filter = PatternMetricFilter.parse(new Configs(), config);
    assertNotSame(filter, MetricFilter.ALL);
    assertTrue(filter.matches("foo", new Counter()));
    assertFalse(filter.matches("boo", new Counter()));
    assertTrue(filter.toString().length() > 0);
  }
View Full Code Here

      "\n }}";

    Config config = ConfigFactory.parseString(str);
    MetricFilter filter = PatternMetricFilter.parse(new Configs(), config);
    assertNotSame(filter, MetricFilter.ALL);
    assertTrue(filter.matches("foo", new Counter()));
    assertTrue(filter.matches("boo", new Counter()));
    assertTrue(filter.toString().length() > 0);
  }
View Full Code Here

        throw new RuntimeException(t);       
      }
    };
   
    MetricRegistry metricRegistry = new MetricRegistry();
    metricRegistry.register("myCounter", new Counter());
   
    HealthCheckRegistry healthChecks = new HealthCheckRegistry();
    healthChecks.register("foo", new HealthCheck() {     
      @Override
      protected Result check() throws Exception {
View Full Code Here

    assertSame(target.timer, timer);
    assertSame(target2.timer, timer);

    assertNotNull(target.counter);
    assertNotNull(target2.counter);
    Counter ctr = (Counter) forMetricField(metricRegistry, MetricAnnotationTest.Target.class, "counter");
    assertSame(target.counter, ctr);
    assertSame(target2.counter, ctr);

    assertNotNull(target.histogram);
    assertNotNull(target2.histogram);
View Full Code Here

TOP

Related Classes of com.codahale.metrics.Counter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.