Package com.codahale.metrics

Examples of com.codahale.metrics.Meter


        assertThat(meter.getCount()).isEqualTo(1);
    }

    @Test
    public void exceptionMeteredMethodsAreExceptionMetered() {
        final Meter meter = registry.meter(name(InstrumentedResource.class,
                "exceptionMetered",
                "exceptions"));

        assertThat(target("exception-metered")
                .request()
                .get(String.class))
                .isEqualTo("fuh");

        assertThat(meter.getCount()).isZero();

        try {
            target("exception-metered")
                    .queryParam("splode", true)
                    .request()
                    .get(String.class);

            failBecauseExceptionWasNotThrown(ProcessingException.class);
        } catch (ProcessingException e) {
            assertThat(e.getCause()).isInstanceOf(IOException.class);
        }

        assertThat(meter.getCount()).isEqualTo(1);
    }
View Full Code Here


    @Mock private HttpHeaders headers;

    @BeforeMethod
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        Meter meter = mock(Meter.class);
        when(metricRegistry.meter(anyString())).thenReturn(meter);

        ChannelBuffer channelBuffer = ChannelBuffers.copiedBuffer("{}", Charset.defaultCharset());

        when(headers.get(HttpHeaders.Names.CONNECTION)).thenReturn(HttpHeaders.Values.CLOSE);
View Full Code Here

    try {
      final MetricRegistry registry = new MetricRegistry();
      r0 = startConsoleReporter(registry);
      r1 = startInfluxdbReporter(registry);

      final Meter mymeter0 = registry.meter("MyMeter.0");
      for (int i = 0; i < 100; i++) {
        mymeter0.mark();
        mymeter0.mark(Math.round(Math.random() * 100.0));
        Thread.sleep(Math.round(Math.random() * 1000.0));
      }
    } catch (Exception exc) {
      exc.printStackTrace();
      System.exit(1);
View Full Code Here

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

            for (Map.Entry<String, Meter> meterEntry : meters.entrySet()) {
                DemuxedKey key = new DemuxedKey(meterEntry.getKey());
                Meter meter = meterEntry.getValue();

                count(key, meter, "meterSum", data);
            }

            for (Map.Entry<String, Histogram> histogramEntry : histograms.entrySet()) {
View Full Code Here

    public Object getValueAndReset() {
        final Map<String, Number> ret = new HashMap<String, Number>();

        for (Map.Entry<String, Meter> entry : registry.getMeters().entrySet()) {
            String prefix = entry.getKey() + "/";
            Meter meter = entry.getValue();

            ret.put(prefix + "count", meter.getCount());
            ret.put(prefix + "mean_rate", meter.getMeanRate());
            ret.put(prefix + "m1_rate", meter.getOneMinuteRate());
            ret.put(prefix + "m5_rate", meter.getFiveMinuteRate());
            ret.put(prefix + "m15_rate", meter.getFifteenMinuteRate());
        }
        return ret;
    }
View Full Code Here

        }

        if (method.getMethod().isAnnotationPresent(Metered.class)) {
            final Metered annotation = method.getMethod().getAnnotation(Metered.class);
            final String name = chooseName(annotation.name(), annotation.absolute(), method);
            final Meter meter = registry.meter(name);
            dispatcher = new MeteredRequestDispatcher(dispatcher, meter);
        }

        if (method.getMethod().isAnnotationPresent(ExceptionMetered.class)) {
            final ExceptionMetered annotation = method.getMethod()
                                                      .getAnnotation(ExceptionMetered.class);
            final String name = chooseName(annotation.name(),
                                           annotation.absolute(),
                                           method,
                                           ExceptionMetered.DEFAULT_NAME_SUFFIX);
            final Meter meter = registry.meter(name);
            dispatcher = new ExceptionMeteredRequestDispatcher(dispatcher,
                                                               meter,
                                                               annotation.cause());
        }
View Full Code Here

        this.errorCount = new AtomicLong();
        this.putCount = new AtomicLong();
        this.takeCount = new AtomicLong();
  this.averageQueueSize = AverageQueueSize.get();
  this.averageQueueSize.add(this);
  this.putRateMeter = new Meter();
  this.takeRateMeter = new Meter();
    }
View Full Code Here

    /**
     * Creates a Timer.
     */
    private Timer(final String name) {
        this.name = name;
        failed = new Meter(CLOCK);
    }
View Full Code Here

    }

    @Override
    protected void doProcess(Exchange exchange, MeterEndpoint endpoint, MetricRegistry registry, String metricsName) throws Exception {
        Message in = exchange.getIn();
        Meter meter = registry.meter(metricsName);
        Long mark = endpoint.getMark();
        Long finalMark = getLongHeader(in, HEADER_METER_MARK, mark);
        if (finalMark == null) {
            meter.mark();
        } else {
            meter.mark(finalMark);
        }
    }
View Full Code Here

    static final String METERED_SUFFIX = "meter";

    static MethodInterceptor forMethod(MetricRegistry metricRegistry, Class<?> klass, Method method) {
        final Metered annotation = method.getAnnotation(Metered.class);
        if (annotation != null) {
            final Meter meter = metricRegistry.meter(determineName(annotation, klass, method));
            return new MeteredInterceptor(meter);
        }
        return null;
    }
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.