use of com.codahale.metrics.Snapshot in project indy by Commonjava.
the class IndyZabbixReporter method report.
@SuppressWarnings("rawtypes")
@Override
public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) {
final long clock = System.currentTimeMillis() / 1000;
List<DataObject> dataObjectList = new LinkedList<DataObject>();
for (Map.Entry<String, Gauge> entry : gauges.entrySet()) {
DataObject dataObject = toDataObject(entry.getKey(), "", String.valueOf(entry.getValue().getValue()), clock);
dataObjectList.add(dataObject);
}
for (Map.Entry<String, Counter> entry : counters.entrySet()) {
DataObject dataObject = toDataObject(entry.getKey(), "", String.valueOf(entry.getValue().getCount()), clock);
dataObjectList.add(dataObject);
}
for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
Histogram histogram = entry.getValue();
Snapshot snapshot = histogram.getSnapshot();
addSnapshotDataObject(entry.getKey(), snapshot, clock, dataObjectList);
}
for (Map.Entry<String, Meter> entry : meters.entrySet()) {
Meter meter = entry.getValue();
addMeterDataObject(entry.getKey(), meter, clock, dataObjectList);
}
for (Map.Entry<String, Timer> entry : timers.entrySet()) {
Timer timer = entry.getValue();
addMeterDataObject(entry.getKey(), timer, clock, dataObjectList);
addSnapshotDataObjectWithConvertDuration(entry.getKey(), timer.getSnapshot(), clock, dataObjectList);
}
try {
SenderResult senderResult = indyZabbixSender.send(dataObjectList, clock);
if (!senderResult.success()) {
logger.warn("report metrics to zabbix not success!" + senderResult);
} else if (logger.isDebugEnabled()) {
logger.info("report metrics to zabbix success. " + senderResult);
}
} catch (IOException e) {
logger.error("report metrics to zabbix error! " + e);
e.printStackTrace();
} catch (IndyMetricsException e) {
logger.error("Indy metrics config error " + e);
e.printStackTrace();
} catch (IndyHttpException e) {
logger.error("Indy http client error " + e);
e.printStackTrace();
}
}
use of com.codahale.metrics.Snapshot in project incubator-gobblin by apache.
the class OutputStreamReporter method printTimer.
private void printTimer(Timer timer) {
final Snapshot snapshot = timer.getSnapshot();
this.outputBufferPrintStream.printf(locale, " count = %d%n", timer.getCount());
this.outputBufferPrintStream.printf(locale, " mean rate = %2.2f calls/%s%n", convertRate(timer.getMeanRate()), getRateUnit());
this.outputBufferPrintStream.printf(locale, " 1-minute rate = %2.2f calls/%s%n", convertRate(timer.getOneMinuteRate()), getRateUnit());
this.outputBufferPrintStream.printf(locale, " 5-minute rate = %2.2f calls/%s%n", convertRate(timer.getFiveMinuteRate()), getRateUnit());
this.outputBufferPrintStream.printf(locale, " 15-minute rate = %2.2f calls/%s%n", convertRate(timer.getFifteenMinuteRate()), getRateUnit());
this.outputBufferPrintStream.printf(locale, " min = %2.2f %s%n", convertDuration(snapshot.getMin()), getDurationUnit());
this.outputBufferPrintStream.printf(locale, " max = %2.2f %s%n", convertDuration(snapshot.getMax()), getDurationUnit());
this.outputBufferPrintStream.printf(locale, " mean = %2.2f %s%n", convertDuration(snapshot.getMean()), getDurationUnit());
this.outputBufferPrintStream.printf(locale, " stddev = %2.2f %s%n", convertDuration(snapshot.getStdDev()), getDurationUnit());
this.outputBufferPrintStream.printf(locale, " median = %2.2f %s%n", convertDuration(snapshot.getMedian()), getDurationUnit());
this.outputBufferPrintStream.printf(locale, " 75%% <= %2.2f %s%n", convertDuration(snapshot.get75thPercentile()), getDurationUnit());
this.outputBufferPrintStream.printf(locale, " 95%% <= %2.2f %s%n", convertDuration(snapshot.get95thPercentile()), getDurationUnit());
this.outputBufferPrintStream.printf(locale, " 98%% <= %2.2f %s%n", convertDuration(snapshot.get98thPercentile()), getDurationUnit());
this.outputBufferPrintStream.printf(locale, " 99%% <= %2.2f %s%n", convertDuration(snapshot.get99thPercentile()), getDurationUnit());
this.outputBufferPrintStream.printf(locale, " 99.9%% <= %2.2f %s%n", convertDuration(snapshot.get999thPercentile()), getDurationUnit());
}
use of com.codahale.metrics.Snapshot in project bookkeeper by apache.
the class CodahaleOpStatsLogger method toOpStatsData.
/**
* This function should go away soon (hopefully).
*/
public synchronized OpStatsData toOpStatsData() {
long numFailed = fail.getCount();
long numSuccess = success.getCount();
Snapshot s = success.getSnapshot();
double avgLatencyMillis = s.getMean();
double[] defaultPercentiles = { 10, 50, 90, 99, 99.9, 99.99 };
long[] latenciesMillis = new long[defaultPercentiles.length];
Arrays.fill(latenciesMillis, Long.MAX_VALUE);
for (int i = 0; i < defaultPercentiles.length; i++) {
latenciesMillis[i] = (long) s.getValue(defaultPercentiles[i] / 100);
}
return new OpStatsData(numSuccess, numFailed, avgLatencyMillis, latenciesMillis);
}
use of com.codahale.metrics.Snapshot in project infrautils by opendaylight.
the class MetricsFileReporter method printSampling.
private static void printSampling(PrintWriter pw, Sampling sampling) {
Snapshot snapshot = sampling.getSnapshot();
printWithSeparator(pw, "min", snapshot.getMin());
printWithSeparator(pw, "max", snapshot.getMax());
printWithSeparator(pw, "mean", snapshot.getMean());
}
use of com.codahale.metrics.Snapshot in project stdlib by petergeneric.
the class MetricSerialiser method serialise.
public MetricsHistogram serialise(String name, Histogram histo) {
Snapshot snapshot = histo.getSnapshot();
final long count = histo.getCount();
return new MetricsHistogram(name, count, snapshot.size(), snapshot.getMin(), snapshot.getMax(), snapshot.getStdDev(), snapshot.getMean(), snapshot.getMedian(), snapshot.get75thPercentile(), snapshot.get95thPercentile(), snapshot.get98thPercentile(), snapshot.get99thPercentile(), snapshot.get999thPercentile());
}
Aggregations