Example usage for com.amazonaws.services.cloudwatch.model MetricDatum withStatisticValues

List of usage examples for com.amazonaws.services.cloudwatch.model MetricDatum withStatisticValues

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudwatch.model MetricDatum withStatisticValues.

Prototype


public MetricDatum withStatisticValues(StatisticSet statisticValues) 

Source Link

Document

The statistical values for the metric.

Usage

From source file:com.blacklocus.metrics.CloudWatchReporter.java

License:Apache License

/**
 * @param rescale the submitted sum by this multiplier. 1.0 is the identity (no rescale).
 *///from   www. j av a 2  s  .  c om
void reportSampling(Map.Entry<String, ? extends Sampling> entry, String type, 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(entry.getKey());
    Iterables.addAll(data, key.newDatums(type, new Function<MetricDatum, MetricDatum>() {
        @Override
        public MetricDatum apply(MetricDatum datum) {
            return datum.withStatisticValues(statisticSet);
        }
    }));
}

From source file:com.jlhood.metrics.CloudWatchReporter.java

License:Apache License

/**
 * @param rescale the submitted sum by this multiplier. 1.0 is the identity (no rescale).
 *///from  ww w .j a  v  a  2s .c  o  m
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);
        }
    }));
}