Package com.codahale.metrics

Examples of com.codahale.metrics.Histogram


     * {@inheritDoc}
     */
    @Override
    public Histogram buildHistogram() {
        final SlidingTimeWindowReservoir reservoir = new SlidingTimeWindowReservoir(windowInSeconds, TimeUnit.SECONDS);
        return new Histogram(reservoir);
    }
View Full Code Here


     *
     * @param name Metric name.
     * @param value Metric value.
     */
    public void update(final String name, final long value) {
        final Histogram histogram = getHistogram(name);
        histogram.update(value);
    }
View Full Code Here

     *
     * @param name Name for metric.
     * @return Histogram.
     */
    private Histogram getHistogram(final String name) {
        Histogram histogram = metricRegistry.getHistograms().get(name);
        if (histogram == null) {
            histogram = histogramBuilder.buildHistogram();
            metricRegistry.register(name, histogram);
        }
        return histogram;
View Full Code Here

     */
    @Override
    public Histogram buildHistogram() {

        final SlidingWindowReservoir slidingWindowReservoir = new SlidingWindowReservoir(nrOfMeasurements);
        return new Histogram(slidingWindowReservoir);
    }
View Full Code Here

        schedulerHandleTimerMap.put(e, timer);
      }
      // histogram for scheduler operations (Samplers)
      schedulerHistogramList = new ArrayList<Histogram>();
      histogramTimerMap = new HashMap<Histogram, Timer>();
      Histogram schedulerAllocateHistogram = new Histogram(
              new SlidingWindowReservoir(SAMPLING_SIZE));
      metrics.register("sampler.scheduler.operation.allocate.timecost",
              schedulerAllocateHistogram);
      schedulerHistogramList.add(schedulerAllocateHistogram);
      histogramTimerMap.put(schedulerAllocateHistogram, schedulerAllocateTimer);
      Histogram schedulerHandleHistogram = new Histogram(
              new SlidingWindowReservoir(SAMPLING_SIZE));
      metrics.register("sampler.scheduler.operation.handle.timecost",
              schedulerHandleHistogram);
      schedulerHistogramList.add(schedulerHandleHistogram);
      histogramTimerMap.put(schedulerHandleHistogram, schedulerHandleTimer);
      for (SchedulerEventType e : SchedulerEventType.values()) {
        Histogram histogram = new Histogram(
                new SlidingWindowReservoir(SAMPLING_SIZE));
        metrics.register(
                "sampler.scheduler.operation.handle." + e + ".timecost",
                histogram);
        schedulerHistogramList.add(histogram);
View Full Code Here

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

            for (Map.Entry<String, Histogram> histogramEntry : histograms.entrySet()) {
                DemuxedKey key = new DemuxedKey(histogramEntry.getKey());
                Histogram histogram = histogramEntry.getValue();

                count(key, histogram, "histogramCount", data);
                sampling(key, histogram, 1.0, "histogramSet", data);
            }
View Full Code Here

        schedulerHandleTimerMap.put(e, timer);
      }
      // histogram for scheduler operations (Samplers)
      schedulerHistogramList = new ArrayList<Histogram>();
      histogramTimerMap = new HashMap<Histogram, Timer>();
      Histogram schedulerAllocateHistogram = new Histogram(
              new SlidingWindowReservoir(SAMPLING_SIZE));
      metrics.register("sampler.scheduler.operation.allocate.timecost",
              schedulerAllocateHistogram);
      schedulerHistogramList.add(schedulerAllocateHistogram);
      histogramTimerMap.put(schedulerAllocateHistogram, schedulerAllocateTimer);
      Histogram schedulerHandleHistogram = new Histogram(
              new SlidingWindowReservoir(SAMPLING_SIZE));
      metrics.register("sampler.scheduler.operation.handle.timecost",
              schedulerHandleHistogram);
      schedulerHistogramList.add(schedulerHandleHistogram);
      histogramTimerMap.put(schedulerHandleHistogram, schedulerHandleTimer);
      for (SchedulerEventType e : SchedulerEventType.values()) {
        Histogram histogram = new Histogram(
                new SlidingWindowReservoir(SAMPLING_SIZE));
        metrics.register(
                "sampler.scheduler.operation.handle." + e + ".timecost",
                histogram);
        schedulerHistogramList.add(histogram);
View Full Code Here

        final Map<String, Number> ret = new HashMap<String, Number>();

        for (Map.Entry<String, Histogram> entry : registry.getHistograms()
                .entrySet()) {
            String prefix = entry.getKey() + "/";
            Histogram histogram = entry.getValue();
            Snapshot snapshot = histogram.getSnapshot();

            ret.put(prefix + "count", histogram.getCount());
            ret.put(prefix + "max", snapshot.getMax());
            ret.put(prefix + "min", snapshot.getMin());
            ret.put(prefix + "stddev", snapshot.getStdDev());
            ret.put(prefix + "p50", snapshot.getMedian());
            ret.put(prefix + "p75", snapshot.get75thPercentile());
View Full Code Here

    }

    @Override
    protected void doProcess(Exchange exchange, HistogramEndpoint endpoint, MetricRegistry registry, String metricsName) throws Exception {
        Message in = exchange.getIn();
        Histogram histogram = registry.histogram(metricsName);
        Long value = endpoint.getValue();
        Long finalValue = getLongHeader(in, HEADER_HISTOGRAM_VALUE, value);
        if (finalValue != null) {
            histogram.update(finalValue);
        } else {
            LOG.warn("Cannot update histogram \"{}\" with null value", metricsName);
        }
    }
View Full Code Here

      Thread.sleep(8000);

      ds.close();

      final MetricRegistry registry = new MetricRegistry();
      final Histogram histogram = registry.histogram("foo");

      for (final FastWorker w : workers) {
         histogram.update(w.iterations);
      }
     
      final Logger logger = LoggerFactory.getLogger(getClass());
      final Snapshot snapshot = histogram.getSnapshot();
      logger.info("Min: {}, Max: {}. Median: {}", snapshot.getMin(), snapshot.getMax(), (int) snapshot.getMedian());
      logger.info("75%: {}, 95%: {}, 99%: {}", (int) snapshot.get75thPercentile(), (int)snapshot.get95thPercentile(), (int)snapshot.get99thPercentile());
   }
View Full Code Here

TOP

Related Classes of com.codahale.metrics.Histogram

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.