Package com.yammer.metrics.stats

Examples of com.yammer.metrics.stats.Snapshot


    private String getShortValueSizeReport() {
      return getShortHistogramReport(this.valueSize);
    }

    private String getShortHistogramReport(final Histogram h) {
      Snapshot sn = h.getSnapshot();
      return "mean=" + DOUBLE_FORMAT.format(h.mean()) +
        ", min=" + DOUBLE_FORMAT.format(h.min()) +
        ", max=" + DOUBLE_FORMAT.format(h.max()) +
        ", stdDev=" + DOUBLE_FORMAT.format(h.stdDev()) +
        ", 95th=" + DOUBLE_FORMAT.format(sn.get95thPercentile()) +
        ", 99th=" + DOUBLE_FORMAT.format(sn.get99thPercentile());
    }
View Full Code Here


    }
  }

  /** @return an abbreviated summary of {@code hist}. */
  public static String getShortHistogramReport(final Histogram hist) {
    Snapshot sn = hist.getSnapshot();
    return "mean=" + DOUBLE_FORMAT.format(hist.mean()) +
        ", min=" + DOUBLE_FORMAT.format(hist.min()) +
        ", max=" + DOUBLE_FORMAT.format(hist.max()) +
        ", stdDev=" + DOUBLE_FORMAT.format(hist.stdDev()) +
        ", 95th=" + DOUBLE_FORMAT.format(sn.get95thPercentile()) +
        ", 99th=" + DOUBLE_FORMAT.format(sn.get99thPercentile());
  }
View Full Code Here

        ", 99th=" + DOUBLE_FORMAT.format(sn.get99thPercentile());
  }

  /** @return a summary of {@code hist}. */
  public static String getHistogramReport(final Histogram hist) {
    Snapshot sn = hist.getSnapshot();
    return ", mean=" + DOUBLE_FORMAT.format(hist.mean()) +
        ", min=" + DOUBLE_FORMAT.format(hist.min()) +
        ", max=" + DOUBLE_FORMAT.format(hist.max()) +
        ", stdDev=" + DOUBLE_FORMAT.format(hist.stdDev()) +
        ", 50th=" + DOUBLE_FORMAT.format(sn.getMedian()) +
        ", 75th=" + DOUBLE_FORMAT.format(sn.get75thPercentile()) +
        ", 95th=" + DOUBLE_FORMAT.format(sn.get95thPercentile()) +
        ", 99th=" + DOUBLE_FORMAT.format(sn.get99thPercentile()) +
        ", 99.9th=" + DOUBLE_FORMAT.format(sn.get999thPercentile()) +
        ", 99.99th=" + DOUBLE_FORMAT.format(sn.getValue(0.9999)) +
        ", 99.999th=" + DOUBLE_FORMAT.format(sn.getValue(0.99999));
  }
View Full Code Here

    public void processHistogram(MetricName name, Histogram histogram, PrintStream stream) {
     
      stream.append(TABLE_BEGIN);
      header(name.getName(), stream);
      final Snapshot snapshot = histogram.getSnapshot();
      stream.printf("<tr><td>min</td><td>%2.2f</td></tr>", histogram.min());
      stream.printf("<tr><td>max</td><td>%2.2f</td></tr>", histogram.max());
      stream.printf("<tr><td>mean</td><td>%2.2f</td></tr>", histogram.mean());
      stream.printf("<tr><td>stddev</td><td>%2.2f</td></tr>", histogram.stdDev());
      snapShotRows(snapshot, stream);
View Full Code Here

      stream.append(TABLE_BEGIN);
      header(name.getName(), stream);
     
      meterRows(timer, stream);
      String durationUnit = abbrev(timer.durationUnit());
      final Snapshot snapshot = timer.getSnapshot();
      stream.printf("<tr><td>min</td><td>%2.2f %s</td></tr>", timer.min(), durationUnit);
      stream.printf("<tr><td>max</td><td>%2.2f %s</td></tr>", timer.max(), durationUnit);
      stream.printf("<tr><td>mean</td><td>%2.2f %s</td></tr>", timer.mean(), durationUnit);
      stream.printf("<tr><td>stddev</td><td>%2.2f %s</td></tr>", timer.stdDev(), durationUnit);
      snapShotRows(snapshot, stream);
View Full Code Here

 
  public class Data {
    double median, min, max;

    public Data(Histogram metric) {
      Snapshot snapshot = metric.getSnapshot();
      this.median = snapshot.getMedian();
      this.min = metric.min();
      this.max = metric.max();
    }
View Full Code Here

        newEvent().time(epoch).service(service(name, "mean")).metric(metric.mean()).send();
        newEvent().time(epoch).service(service(name, "stddev")).metric(metric.stdDev()).send();
    }

    public void sendSample(MetricName name, Sampling metric, Long epoch) {
        final Snapshot s = metric.getSnapshot();
        newEvent().time(epoch).service(service(name, ".5")).metric(s.getMedian()).send();
        newEvent().time(epoch).service(service(name, ".75")).metric(s.get75thPercentile()).send();
        newEvent().time(epoch).service(service(name, ".95")).metric(s.get95thPercentile()).send();
        newEvent().time(epoch).service(service(name, ".98")).metric(s.get98thPercentile()).send();
        newEvent().time(epoch).service(service(name, ".99")).metric(s.get99thPercentile()).send();
        newEvent().time(epoch).service(service(name, ".999")).metric(s.get999thPercentile()).send();
    }
View Full Code Here

    }

    @Override
    public void processHistogram(final MetricName name,
            final Histogram histogram, final PrintStream stream) {
        final Snapshot snapshot = histogram.getSnapshot();
        stream.printf(locale, "               min = %,2.2f\n", histogram.min());
        stream.printf(locale, "               max = %,2.2f\n", histogram.max());
        stream.printf(locale, "              mean = %,2.2f\n", histogram.mean());
        stream.printf(locale, "            stddev = %,2.2f\n",
                histogram.stdDev());
        stream.printf(locale, "            median = %,2.2f\n",
                snapshot.getMedian());
        stream.printf(locale, "              75%% <= %,2.2f\n",
                snapshot.get75thPercentile());
        stream.printf(locale, "              95%% <= %,2.2f\n",
                snapshot.get95thPercentile());
        stream.printf(locale, "              98%% <= %,2.2f\n",
                snapshot.get98thPercentile());
        stream.printf(locale, "              99%% <= %,2.2f\n",
                snapshot.get99thPercentile());
        stream.printf(locale, "            99.9%% <= %,2.2f\n",
                snapshot.get999thPercentile());
    }
View Full Code Here

    @Override
    public void processTimer(final MetricName name, final Timer timer,
            final PrintStream stream) {
        processMeter(name, timer, stream);
        final String durationUnit = abbrev(timer.durationUnit());
        final Snapshot snapshot = timer.getSnapshot();
        stream.printf(locale, "               min = %,2.2f %s\n", timer.min(),
                durationUnit);
        stream.printf(locale, "               max = %,2.2f %s\n", timer.max(),
                durationUnit);
        stream.printf(locale, "              mean = %,2.2f %s\n", timer.mean(),
                durationUnit);
        stream.printf(locale, "            stddev = %,2.2f %s\n",
                timer.stdDev(), durationUnit);
        stream.printf(locale, "            median = %,2.2f %s\n",
                snapshot.getMedian(), durationUnit);
        stream.printf(locale, "              75%% <= %,2.2f %s\n",
                snapshot.get75thPercentile(), durationUnit);
        stream.printf(locale, "              95%% <= %,2.2f %s\n",
                snapshot.get95thPercentile(), durationUnit);
        stream.printf(locale, "              98%% <= %,2.2f %s\n",
                snapshot.get98thPercentile(), durationUnit);
        stream.printf(locale, "              99%% <= %,2.2f %s\n",
                snapshot.get99thPercentile(), durationUnit);
        stream.printf(locale, "            99.9%% <= %,2.2f %s\n",
                snapshot.get999thPercentile(), durationUnit);
    }
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;

        // 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);
        }

        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

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.