Package com.codahale.metrics

Examples of com.codahale.metrics.Histogram


      try {
         Connection connection = ds.getConnection();
         PoolUtilities.quietlySleep(250L);
         connection.close();

         Histogram histo = metricRegistry.getHistograms(new MetricFilter() {
            /** {@inheritDoc} */
            @Override
            public boolean matches(String name, Metric metric)
            {
               return "test.pool.Usage".equals(MetricRegistry.name("test", "pool", "Usage"));
            }
         }).values().iterator().next();

         Assert.assertEquals(1, histo.getCount());
         double seventyFifth = histo.getSnapshot().get75thPercentile();
         Assert.assertTrue("Seventy-fith percentile less than 250ms: " + seventyFifth, seventyFifth >= 250.0);
      }
      finally {
         ds.close();
      }
View Full Code Here


    @Override
    public void addSampler(String group, String name, int period, int interval, Variable<Long> variable) {
        if (scheduler == null) {
            throw new IllegalStateException("scheduler not set, cannot sample");
        }
        Histogram histogram = new Histogram(new ExponentiallyDecayingReservoir());
        Sampler sampler = new Sampler(variable, histogram);
        scheduler.scheduleAtFixedRate(sampler, 0, interval, TimeUnit.SECONDS);
        String key = MetricRegistry.name(group, name, "histogram");
        try {
            histogramsLock.lock();
View Full Code Here

    assertSame(target.counter, ctr);
    assertSame(target2.counter, ctr);

    assertNotNull(target.histogram);
    assertNotNull(target2.histogram);
    Histogram hist = (Histogram) forMetricField(metricRegistry, MetricAnnotationTest.Target.class, "histogram");
    assertSame(target.histogram, hist);
    assertSame(target2.histogram, hist);

    assertNotNull(target.uniformHistogram);
    assertNotNull(target2.uniformHistogram);
    Histogram uniHist = (Histogram) forMetricField(metricRegistry, MetricAnnotationTest.Target.class, "uniformHistogram");
    assertSame(target.uniformHistogram, uniHist);
    assertSame(target2.uniformHistogram, uniHist);
  }
View Full Code Here

  @Override
  public void set(Metric<?> value) {
    String name = value.getName();
    if (name.startsWith("histogram")) {
      long longValue = value.getValue().longValue();
      Histogram metric = this.registry.histogram(name);
      metric.update(longValue);
    }
    else if (name.startsWith("timer")) {
      long longValue = value.getValue().longValue();
      Timer metric = this.registry.timer(name);
      metric.update(longValue, TimeUnit.MILLISECONDS);
    }
    else {
      final double gauge = value.getValue().doubleValue();
      Object lock = null;
      if (this.gaugeLocks.containsKey(name)) {
View Full Code Here

        return t;
    }

    public static synchronized Histogram newHistogram(String name)
    {
        Histogram h = (Histogram) _registered.get(name);
        if (h == null) {
            // default would be ExpDecayingReservoir; but let's make explicit
            h = _metrics.register(name, new Histogram(new ExponentiallyDecayingReservoir()));
            _registered.put(name,  h);
        }
        return h;
    }
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

    return ret;
  }

  public static JStormHistogram registerHistograms(String name) {
    LOG.info("Register Metric " + name);
    Histogram instance = metrics.histogram(name);

    return new JStormHistogram(name, instance);
  }
View Full Code Here

    }
  }
 
  public void updateFromHistogramData(Map<String, Histogram> histogramMap) {
    for(Entry<String, Histogram> entry : histogramMap.entrySet()) {
      Histogram histogram = entry.getValue();
      HistogramData histogramData = new HistogramData();
      histogramData.setCount(histogram.getCount());
      histogramData.setMax(histogram.getSnapshot().getMax());
      histogramData.setMin(histogram.getSnapshot().getMin());
      histogramData.setMean(histogram.getSnapshot().getMean());
      histogramData.setMedian(histogram.getSnapshot().getMedian());
      histogramData.setStdDev(histogram.getSnapshot().getStdDev());
      histogramData.setPercent75th(histogram.getSnapshot().get75thPercentile());
      histogramData.setPercent95th(histogram.getSnapshot().get95thPercentile());
      histogramData.setPercent98th(histogram.getSnapshot().get98thPercentile());
      histogramData.setPercent99th(histogram.getSnapshot().get99thPercentile());
      histogramData.setPercent999th(histogram.getSnapshot().get999thPercentile());
      histogramDataMap.put(entry.getKey(), histogramData);
    }
  }
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.