Package com.yammer.metrics.stats

Examples of com.yammer.metrics.stats.Snapshot


  @Override
  public void snapshot(MetricsRecordBuilder metricsRecordBuilder, boolean all) {
    if (all || changed()) {
      clearChanged();
      final Snapshot s = sample.getSnapshot();
      metricsRecordBuilder.addCounter(name + NUM_OPS_METRIC_NAME, "", count.get());
      metricsRecordBuilder.addGauge(name + MIN_METRIC_NAME, "", getMin());
      metricsRecordBuilder.addGauge(name + MAX_METRIC_NAME,  "", getMax());
      metricsRecordBuilder.addGauge(name + MEAN_METRIC_NAME, "", getMean());

      metricsRecordBuilder.addGauge(name + MEDIAN_METRIC_NAME, "", s.getMedian());
      metricsRecordBuilder.addGauge(name + SEVENTY_FIFTH_PERCENTILE_METRIC_NAME, "", s.get75thPercentile());
      metricsRecordBuilder.addGauge(name + NINETY_FIFTH_PERCENTILE_METRIC_NAME, "", s.get95thPercentile());
      metricsRecordBuilder.addGauge(name + NINETY_NINETH_PERCENTILE_METRIC_NAME, "", s.get99thPercentile());
    }
  }
View Full Code Here


      for (int i = 0; i < 1000; i++) {
          sample.update(i);
      }
      Assert.assertEquals(100, sample.size());
     
      final Snapshot snapshot = sample.getSnapshot();
      Assert.assertEquals(100, snapshot.size());

      for (double i : snapshot.getValues()) {
        Assert.assertTrue(i >= 0.0 && i < 1000.0);
      }
  }
View Full Code Here

      for (int i = 0; i < 10; i++) {
          sample.update(i);
      }
      Assert.assertEquals(10, sample.size());

      final Snapshot snapshot = sample.getSnapshot();
      Assert.assertEquals(10, sample.size());

      for (double i : snapshot.getValues()) {
        Assert.assertTrue(i >= 0.0 && i < 1000.0);
      }
  }
View Full Code Here

    for (int i = 0; i < data.length; i++) {
      data[i] = (long) (r.nextGaussian() * 10000.0);
      h.update(data[i]);
    }

    final Snapshot s = h.getSnapshot();
    Arrays.sort(data);

    // as long as the histogram chooses an item with index N+/-slop, accept it
    final int slop = 20;

    // make sure the median, 75th percentile and 95th percentile are good
    final int medianIndex = data.length / 2;
    final long minAcceptableMedian = data[safeIndex(medianIndex - slop,
        data.length)];
    final long maxAcceptableMedian = data[safeIndex(medianIndex + slop,
        data.length)];
    Assert.assertTrue(s.getMedian() >= minAcceptableMedian
        && s.getMedian() <= maxAcceptableMedian);

    final int seventyFifthIndex = (int) (data.length * 0.75);
    final long minAcceptableseventyFifth = data[safeIndex(seventyFifthIndex
        - slop, data.length)];
    final long maxAcceptableseventyFifth = data[safeIndex(seventyFifthIndex
        + slop, data.length)];
    Assert.assertTrue(s.get75thPercentile() >= minAcceptableseventyFifth
        && s.get75thPercentile() <= maxAcceptableseventyFifth);

    final int ninetyFifthIndex = (int) (data.length * 0.95);
    final long minAcceptableninetyFifth = data[safeIndex(ninetyFifthIndex
        - slop, data.length)];
    final long maxAcceptableninetyFifth = data[safeIndex(ninetyFifthIndex
        + slop, data.length)];
    Assert.assertTrue(s.get95thPercentile() >= minAcceptableninetyFifth
        && s.get95thPercentile() <= maxAcceptableninetyFifth);

  }
View Full Code Here

    metric.putToDoubleMap("min", histogram.min());
    metric.putToDoubleMap("max", histogram.max());
    metric.putToDoubleMap("mean", histogram.mean());
    metric.putToDoubleMap("stdDev", histogram.stdDev());

    Snapshot snapshot = histogram.getSnapshot();
    metric.putToDoubleMap("median", snapshot.getMedian());
    metric.putToDoubleMap("75%", snapshot.get75thPercentile());
    metric.putToDoubleMap("95%", snapshot.get95thPercentile());
    metric.putToDoubleMap("98%", snapshot.get98thPercentile());
    metric.putToDoubleMap("99%", snapshot.get99thPercentile());
    metric.putToDoubleMap("99.9%", snapshot.get999thPercentile());
  }
View Full Code Here

    metric.putToDoubleMap("min", timer.min());
    metric.putToDoubleMap("max", timer.max());
    metric.putToDoubleMap("mean", timer.mean());
    metric.putToDoubleMap("stdDev", timer.stdDev());

    Snapshot snapshot = timer.getSnapshot();
    metric.putToDoubleMap("median", snapshot.getMedian());
    metric.putToDoubleMap("75%", snapshot.get75thPercentile());
    metric.putToDoubleMap("95%", snapshot.get95thPercentile());
    metric.putToDoubleMap("98%", snapshot.get98thPercentile());
    metric.putToDoubleMap("99%", snapshot.get99thPercentile());
    metric.putToDoubleMap("99.9%", snapshot.get999thPercentile());
  }
View Full Code Here

    info.addNumber("min", histogram.min());
    info.addNumber("max", histogram.max());
    info.addNumber("mean", histogram.mean());
    info.addNumber("stdDev", histogram.stdDev());

    Snapshot snapshot = histogram.getSnapshot();
    info.addNumber("median", snapshot.getMedian());
    info.addNumber("75%", snapshot.get75thPercentile());
    info.addNumber("95%", snapshot.get95thPercentile());
    info.addNumber("98%", snapshot.get98thPercentile());
    info.addNumber("99%", snapshot.get99thPercentile());
    info.addNumber("99.9%", snapshot.get999thPercentile());
  }
View Full Code Here

    info.addNumber("min", timer.min());
    info.addNumber("max", timer.max());
    info.addNumber("mean", timer.mean());
    info.addNumber("stdDev", timer.stdDev());

    Snapshot snapshot = timer.getSnapshot();
    info.addNumber("median", snapshot.getMedian());
    info.addNumber("75%", snapshot.get75thPercentile());
    info.addNumber("95%", snapshot.get95thPercentile());
    info.addNumber("98%", snapshot.get98thPercentile());
    info.addNumber("99%", snapshot.get99thPercentile());
    info.addNumber("99.9%", snapshot.get999thPercentile());
  }
View Full Code Here

        output = out;
    }

    public void run()
    {
        Snapshot latency;
        long oldLatency;
        int epoch, total, oldTotal, keyCount, oldKeyCount;

        // creating keyspace and column families
        if (client.getOperation() == Stress.Operations.INSERT || client.getOperation() == Stress.Operations.COUNTER_ADD)
            client.createKeySpaces();

        int threadCount = client.getThreads();
        Consumer[] consumers = new Consumer[threadCount];

        output.println("total,interval_op_rate,interval_key_rate,latency/95th/99th,elapsed_time");

        int itemsPerThread = client.getKeysPerThread();
        int modulo = client.getNumKeys() % threadCount;
        RateLimiter rateLimiter = RateLimiter.create(client.getMaxOpsPerSecond());

        // creating required type of the threads for the test
        for (int i = 0; i < threadCount; i++) {
            if (i == threadCount - 1)
                itemsPerThread += modulo; // last one is going to handle N + modulo items

            consumers[i] = new Consumer(itemsPerThread, rateLimiter);
        }

        Producer producer = new Producer();
        producer.start();

        // starting worker threads
        for (int i = 0; i < threadCount; i++)
            consumers[i].start();

        // initialization of the values
        boolean terminate = false;
        epoch = total = keyCount = 0;

        int interval = client.getProgressInterval();
        int epochIntervals = client.getProgressInterval() * 10;
        long testStartTime = System.currentTimeMillis();

        while (!terminate)
        {
            if (stop)
            {
                producer.stopProducer();

                for (Consumer consumer : consumers)
                    consumer.stopConsume();

                break;
            }

            try
            {
                Thread.sleep(100);
            }
            catch (InterruptedException e)
            {
                throw new RuntimeException(e.getMessage(), e);
            }

            int alive = 0;
            for (Thread thread : consumers)
                if (thread.isAlive()) alive++;

            if (alive == 0)
                terminate = true;

            epoch++;

            if (terminate || epoch > epochIntervals)
            {
                epoch = 0;

                oldTotal = total;
                oldKeyCount = keyCount;

                total = client.operations.get();
                keyCount = client.keys.get();
                latency = client.latency.getSnapshot();

                int opDelta = total - oldTotal;
                int keyDelta = keyCount - oldKeyCount;

                long currentTimeInSeconds = (System.currentTimeMillis() - testStartTime) / 1000;

                output.println(String.format("%d,%d,%d,%.1f,%.1f,%.1f,%d",
                                             total,
                                             opDelta / interval,
                                             keyDelta / interval,
                                             latency.getMedian(), latency.get95thPercentile(), latency.get999thPercentile(),
                                             currentTimeInSeconds));
            }
        }

        // if any consumer failed, set the return code to failure.
View Full Code Here

  @Override
  public double sum() { return 0.0; }

  @Override
  public Snapshot getSnapshot() { return new Snapshot(new double[0]); }
View Full Code Here

TOP

Related Classes of com.yammer.metrics.stats.Snapshot

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.