Package com.codahale.metrics

Examples of com.codahale.metrics.Meter


            if(executeMethod.isAnnotationPresent(Metered.class)) {
                Metered annotation = executeMethod.getAnnotation(Metered.class);
                String name = chooseName(annotation.name(),
                                        annotation.absolute(),
                                        task);
                Meter meter = metricRegistry.meter(name);
                taskExecutor = new MeteredTask(taskExecutor, meter);
            }

            if(executeMethod.isAnnotationPresent(ExceptionMetered.class)) {
                ExceptionMetered annotation = executeMethod.getAnnotation(ExceptionMetered.class);
                String name = chooseName(annotation.name(),
                                        annotation.absolute(),
                                        task,
                                        ExceptionMetered.DEFAULT_NAME_SUFFIX);
                Meter exceptionMeter = metricRegistry.meter(name);
                taskExecutor = new ExceptionMeteredTask(taskExecutor, exceptionMeter, annotation.cause());
            }
        } catch (NoSuchMethodException e) {
        }
View Full Code Here


        }
    }

    public static void markNotFound(ColumnFamily CF) {
        synchronized (CF) {
            Meter meter = keyNotFoundInCFMap.get(CF);
            if (meter == null) {
                meter = Metrics.meter(Instrumentation.class, "reads", "Not Found", CF.getName());
                keyNotFoundInCFMap.put(CF, meter);
            }
            meter.mark();
        }
    }
View Full Code Here

    assertEquals(1, timedMethod.getCount());
  }

  @Test
  public void meteredMethod() throws Throwable {
    Meter meteredMethod = forMeteredMethod(metricRegistry, MeteredClassImpl.class, "meteredMethod");

    assertEquals(0, meteredMethod.getCount());

    meteredClass.meteredMethod();
    assertEquals(1, meteredMethod.getCount());
  }
View Full Code Here

        }       
      } catch (IOException e) {
        throw new MorphlineCompilationException("Cannot parse UserAgent database: " + databaseFile, config, e);
      }
     
      Meter numCacheHitsMeter = isMeasuringMetrics() ? getMeter(Metrics.NUM_CACHE_HITS) : null;
      Meter numCacheMissesMeter = isMeasuringMetrics() ? getMeter(Metrics.NUM_CACHE_MISSES) : null;
     
      Config outputFields = getConfigs().getConfig(config, "outputFields", ConfigFactory.empty());
      for (Map.Entry<String, Object> entry : new Configs().getEntrySet(outputFields)) {
        mappings.add(
            new Mapping(
View Full Code Here

    assertNotNull(target);
    assertNotNull(target2);

    assertNotNull(target.theNameForTheMeter);
    assertNotNull(target2.theNameForTheMeter);
    Meter meter = (Meter) forMetricField(metricRegistry, MetricAnnotationTest.Target.class, "theNameForTheMeter");
    assertSame(target.theNameForTheMeter, meter);
    assertSame(target2.theNameForTheMeter, meter);

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

  }

  @Test
  public void meteredMethod() throws Throwable {
    // Verify that the Meter's counter is incremented on method invocation
    Meter meteredMethodMeter = forMeteredMethod(metricRegistry, TestBean.class, "meteredMethod");
    assertNotNull(meteredMethodMeter);
    assertThat(meteredMethodMeter.getCount(), is(0L));
    testBean.meteredMethod();
    assertThat(meteredMethodMeter.getCount(), is(1L));
  }
View Full Code Here

  }

  @Test
  public void exceptionMeteredMethod() throws Throwable {
    // Verify that the Meter's counter is incremented on method invocation
    Meter exceptionMeteredMethodMeter = forExceptionMeteredMethod(metricRegistry, TestBean.class, "exceptionMeteredMethod");
    assertNotNull(exceptionMeteredMethodMeter);
    assertThat(exceptionMeteredMethodMeter.getCount(), is(0L));
    try {
      testBean.exceptionMeteredMethod();
    }
    catch (Throwable t) {}
    assertThat(exceptionMeteredMethodMeter.getCount(), is(1L));
  }
View Full Code Here

    assertEquals(2, timedMethod.getCount());
  }

  @Test
  public void meteredMethod() throws Throwable {
    Meter meteredMethod = forMeteredMethod(metricRegistry, MeteredClass.class, "meteredMethod");

    assertEquals(0, meteredMethod.getCount());

    meteredClass.meteredMethod();
    assertEquals(1, meteredMethod.getCount());
  }
View Full Code Here

    assertEquals(1, meteredMethod.getCount());
  }

  @Test
  public void exceptionMeteredMethod() throws Throwable {
    Meter exceptionMeteredMethod = forExceptionMeteredMethod(metricRegistry, MeteredClass.class, "exceptionMeteredMethod");

    assertEquals(0, exceptionMeteredMethod.getCount());

    // doesn't throw an exception
    meteredClass.exceptionMeteredMethod(null);
    assertEquals(0, exceptionMeteredMethod.getCount());

    // throws the wrong exception
    try {
      meteredClass.exceptionMeteredMethod(RuntimeException.class);
      fail();
    }
    catch (Throwable t) {
      assertTrue(t instanceof RuntimeException);
    }
    assertEquals(0, exceptionMeteredMethod.getCount());

    // throws the right exception
    try {
      meteredClass.exceptionMeteredMethod(BogusException.class);
      fail();
    }
    catch (Throwable t) {
      assertTrue(t instanceof BogusException);
    }
    assertEquals(1, exceptionMeteredMethod.getCount());
  }
View Full Code Here

  }

  @Test
  public void quadruplyMeteredMethod() throws Throwable {
    Timer quadruple_Timed = forTimedMethod(metricRegistry, MeteredClass.class, "quadruplyMeteredMethod");
    Meter quadruple_Metered = forMeteredMethod(metricRegistry, MeteredClass.class, "quadruplyMeteredMethod");
    Meter quadruple_ExceptionMetered = forExceptionMeteredMethod(metricRegistry, MeteredClass.class, "quadruplyMeteredMethod");
    final Counter quadruple_Counted = forCountedMethod(metricRegistry, MeteredClass.class, "quadruplyMeteredMethod");

    assertEquals(0, quadruple_Metered.getCount());
    assertEquals(0, quadruple_Timed.getCount());
    assertEquals(0, quadruple_ExceptionMetered.getCount());
    assertEquals(0, quadruple_Counted.getCount());

    // doesn't throw an exception
    meteredClass.quadruplyMeteredMethod(new Runnable() {
      @Override
      public void run() {
        assertEquals(1, quadruple_Counted.getCount());
      }
    });

    assertEquals(1, quadruple_Metered.getCount());
    assertEquals(1, quadruple_Timed.getCount());
    assertEquals(0, quadruple_ExceptionMetered.getCount());
    assertEquals(0, quadruple_Counted.getCount());

    // throws an exception
    try {
      meteredClass.quadruplyMeteredMethod(new Runnable() {
        @Override
        public void run() {
          assertEquals(1, quadruple_Counted.getCount());
          throw new BogusException();
        }
      });
      fail();
    }
    catch (Throwable t) {
      assertTrue(t instanceof BogusException);
    }
    assertEquals(2, quadruple_Metered.getCount());
    assertEquals(2, quadruple_Timed.getCount());
    assertEquals(1, quadruple_ExceptionMetered.getCount());
    assertEquals(0, quadruple_Counted.getCount());
  }
View Full Code Here

TOP

Related Classes of com.codahale.metrics.Meter

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.