Package com.codahale.metrics

Examples of com.codahale.metrics.Counter


    private MetricRegistry getMockMetricRegistry() {
        final MetricRegistry mockMetricRegistry = mock(MetricRegistry.class);
        final Meter mockMeter = mock(Meter.class);
        final Timer mockTimer = mock(Timer.class);
        final Counter mockCounter = mock(Counter.class);
        when(mockMetricRegistry.meter(anyString())).thenReturn(mockMeter);
        when(mockMetricRegistry.timer(anyString())).thenReturn(mockTimer);
        when(mockMetricRegistry.counter(anyString())).thenReturn(mockCounter);

        return mockMetricRegistry;
View Full Code Here


              "counter.scheduler.operation.allocate");
      schedulerHandleCounter = metrics.counter(
              "counter.scheduler.operation.handle");
      schedulerHandleCounterMap = new HashMap<SchedulerEventType, Counter>();
      for (SchedulerEventType e : SchedulerEventType.values()) {
        Counter counter = metrics.counter(
                "counter.scheduler.operation.handle." + e);
        schedulerHandleCounterMap.put(e, counter);
      }
      // timers for scheduler operations
      int timeWindowSize = conf.getInt(
View Full Code Here

                }
            }

            for (Map.Entry<String, Counter> counterEntry : counters.entrySet()) {
                DemuxedKey key = new DemuxedKey(counterEntry.getKey());
                Counter counter = counterEntry.getValue();

                count(key, counter, "counterSum", data);
            }

            for (Map.Entry<String, Meter> meterEntry : meters.entrySet()) {
View Full Code Here

              "counter.scheduler.operation.allocate");
      schedulerHandleCounter = metrics.counter(
              "counter.scheduler.operation.handle");
      schedulerHandleCounterMap = new HashMap<SchedulerEventType, Counter>();
      for (SchedulerEventType e : SchedulerEventType.values()) {
        Counter counter = metrics.counter(
                "counter.scheduler.operation.handle." + e);
        schedulerHandleCounterMap.put(e, counter);
      }
      // timers for scheduler operations
      int timeWindowSize = conf.getInt(
View Full Code Here

      tajoSystemMetrics.counter("test-group01", "test-item2").inc(2);
      tajoSystemMetrics.counter("test-group02", "test-item1").inc(3);
    }

    SortedMap<String, Counter> counterMap = tajoSystemMetrics.getRegistry().getCounters();
    Counter counter1 = counterMap.get("test-file-group.test-group01.test-item1");
    assertNotNull(counter1);
    assertEquals(10, counter1.getCount());

    Counter counter2 = counterMap.get("test-file-group.test-group01.test-item2");
    assertNotNull(counter2);
    assertEquals(20, counter2.getCount());

    //test findMetricsItemGroup method
    Map<String, Map<String, Counter>> groupItems = reporter.findMetricsItemGroup(counterMap);
    assertEquals(2, groupItems.size());

    Map<String, Counter> group01Items = groupItems.get("test-file-group.test-group01");
    assertEquals(2, group01Items.size());

    counter1 = group01Items.get("test-item1");
    assertNotNull(counter1);
    assertEquals(10, counter1.getCount());

    counter2 = group01Items.get("test-item2");
    assertNotNull(counter2);
    assertEquals(20, counter2.getCount());

    Map<String, Counter> group02Items = groupItems.get("test-file-group.test-group02");
    assertEquals(1, group02Items.size());

    reporter.report();
View Full Code Here

    @Test
    public void testMetricsRegistryFromCamelRegistry() throws Exception {
        // TODO - 12.05.2014, Lauri - is there any better way to set this up?
        MetricRegistry mockRegistry = endpoint.getCamelContext().getRegistry().lookupByNameAndType(MetricsComponent.METRIC_REGISTRY_NAME, MetricRegistry.class);
        Counter mockCounter = Mockito.mock(Counter.class);
        InOrder inOrder = Mockito.inOrder(mockRegistry, mockCounter);
        when(mockRegistry.counter("A")).thenReturn(mockCounter);

        endpoint.expectedMessageCount(1);
        producer.sendBody(new Object());
View Full Code Here

    }

    @Override
    protected void doProcess(Exchange exchange, CounterEndpoint endpoint, MetricRegistry registry, String metricsName) throws Exception {
        Message in = exchange.getIn();
        Counter counter = registry.counter(metricsName);
        Long increment = endpoint.getIncrement();
        Long decrement = endpoint.getDecrement();
        Long finalIncrement = getLongHeader(in, HEADER_COUNTER_INCREMENT, increment);
        Long finalDecrement = getLongHeader(in, HEADER_COUNTER_DECREMENT, decrement);
        if (finalIncrement != null) {
            counter.inc(finalIncrement);
        } else if (finalDecrement != null) {
            counter.dec(finalDecrement);
        } else {
            counter.inc();
        }
    }
View Full Code Here

    @Nullable
    static MethodInterceptor forMethod(MetricRegistry metricRegistry, Class<?> klass, Method method) {
        final Counted annotation = method.getAnnotation(Counted.class);
        if (annotation != null) {
            final Counter counter = metricRegistry.counter(determineName(annotation, klass, method));
            return new CountedInterceptor(counter, annotation);
        }
        return null;
    }
View Full Code Here

    @Test
    public void aCounterAnnotatedMethod() throws Exception {
        instance.doAThing();

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

        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

    @Test
    public void aCounterAnnotatedMethodWithDefaultName() throws Exception {
        instance.doAnotherThing();

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

        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

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.