Java Code Examples for com.codahale.metrics.Sampling#getSnapshot()
The following examples show how to use
com.codahale.metrics.Sampling#getSnapshot() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloudWatchReporter.java From metrics-cloudwatch with Apache License 2.0 | 6 votes |
/** * @param rescale the submitted sum by this multiplier. 1.0 is the identity (no rescale). */ void reportSampling(Map.Entry<String, ? extends Sampling> entry, String typeDimValue, double rescale, List<MetricDatum> data) { Sampling metric = entry.getValue(); Snapshot snapshot = metric.getSnapshot(); double scaledSum = sum(snapshot.getValues()) * rescale; final StatisticSet statisticSet = new StatisticSet() .withSum(scaledSum) .withSampleCount((double) snapshot.size()) .withMinimum((double) snapshot.getMin() * rescale) .withMaximum((double) snapshot.getMax() * rescale); DemuxedKey key = new DemuxedKey(appendGlobalDimensions(entry.getKey())); Iterables.addAll(data, key.newDatums(typeDimName, typeDimValue, new Function<MetricDatum, MetricDatum>() { @Override public MetricDatum apply(MetricDatum datum) { return datum.withStatisticValues(statisticSet); } })); }
Example 2
Source File: AggregateMetricSenderSessionWrapper.java From signalfx-java with Apache License 2.0 | 4 votes |
private void addSampling(String baseName, Sampling sampling) { Metric metric = (Metric)sampling; final Snapshot snapshot = sampling.getSnapshot(); addMetric(metric, baseName, SignalFxReporter.MetricDetails.MEDIAN, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getMedian()); addMetric(metric, baseName, SignalFxReporter.MetricDetails.PERCENT_75, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get75thPercentile()); addMetric(metric, baseName, SignalFxReporter.MetricDetails.PERCENT_95, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get95thPercentile()); addMetric(metric, baseName, SignalFxReporter.MetricDetails.PERCENT_98, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get98thPercentile()); addMetric(metric, baseName, SignalFxReporter.MetricDetails.PERCENT_99, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get99thPercentile()); addMetric(metric, baseName, SignalFxReporter.MetricDetails.PERCENT_999, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get999thPercentile()); addMetric(metric, baseName, SignalFxReporter.MetricDetails.MAX, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getMax()); addMetric(metric, baseName, SignalFxReporter.MetricDetails.MIN, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getMin()); // These are slower to calculate. Only calculate if we need. if (detailsToAdd.contains(SignalFxReporter.MetricDetails.STD_DEV)) { addMetric(metric, baseName, SignalFxReporter.MetricDetails.STD_DEV, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getStdDev()); } if (detailsToAdd.contains(SignalFxReporter.MetricDetails.MEAN)) { addMetric(metric, baseName, SignalFxReporter.MetricDetails.MEAN, SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getMean()); } }