コード例 #1
0
  public void addSampling(String name, Sampling sampling, boolean convert) {
    final Snapshot snapshot = sampling.getSnapshot();
    maybeAdd(MEDIAN, name, convertDuration(snapshot.getMedian(), convert));
    maybeAdd(PCT_75, name, convertDuration(snapshot.get75thPercentile(), convert));
    maybeAdd(PCT_95, name, convertDuration(snapshot.get95thPercentile(), convert));
    maybeAdd(PCT_98, name, convertDuration(snapshot.get98thPercentile(), convert));
    maybeAdd(PCT_99, name, convertDuration(snapshot.get99thPercentile(), convert));
    maybeAdd(PCT_999, name, convertDuration(snapshot.get999thPercentile(), convert));

    if (!omitComplexGauges) {
      final double sum = snapshot.size() * snapshot.getMean();
      final long count = (long) snapshot.size();
      if (count > 0) {
        SourceInformation info = SourceInformation.from(sourceRegex, name);
        MultiSampleGaugeMeasurement measurement;
        try {
          measurement =
              MultiSampleGaugeMeasurement.builder(addPrefix(info.name))
                  .setSource(info.source)
                  .setCount(count)
                  .setSum(convertDuration(sum, convert))
                  .setMax(convertDuration(snapshot.getMax(), convert))
                  .setMin(convertDuration(snapshot.getMin(), convert))
                  .build();
        } catch (IllegalArgumentException e) {
          log.warn("Could not create gauge", e);
          return;
        }
        addMeasurement(measurement);
      }
    }
  }
コード例 #2
0
  private void collectHistogramReports(
      List<DBObject> docs, SortedMap<String, Histogram> histograms, Date timestamp) {
    if (histograms.isEmpty()) return;

    for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
      final BasicDBObject report = getBasicDBObject(timestamp, entry.getKey(), "histogram");
      final Histogram histogram = entry.getValue();

      final Snapshot s = histogram.getSnapshot();
      report.put("count", s.size());
      report.put("75th_percentile", s.get75thPercentile());
      report.put("95th_percentile", s.get95thPercentile());
      report.put("98th_percentile", s.get98thPercentile());
      report.put("99th_percentile", s.get99thPercentile());
      report.put("999th_percentile", s.get999thPercentile());
      report.put("max", s.getMax());
      report.put("min", s.getMin());
      report.put("mean", s.getMean());
      report.put("median", s.getMedian());
      report.put("std_dev", s.getStdDev());
      docs.add(report);
    }
  }
コード例 #3
0
 public int size() {
   return s.size();
 }