Example usage for com.amazonaws.services.cloudwatch.model StandardUnit Count

List of usage examples for com.amazonaws.services.cloudwatch.model StandardUnit Count

Introduction

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

Prototype

StandardUnit Count

To view the source code for com.amazonaws.services.cloudwatch.model StandardUnit Count.

Click Source Link

Usage

From source file:com.amazon.kinesis.streaming.agent.metrics.AbstractMetricsScope.java

License:Open Source License

@Override
public void addCount(String name, long amount) {
    addData(name, amount, StandardUnit.Count);
}

From source file:com.amediamanager.metrics.MetricAspect.java

License:Apache License

protected void emitMetrics(String service, String operation, long startTime, Throwable exception) {
    final MetricDatum latency = newDatum(service, operation, startTime).withMetricName("Latency")
            .withUnit(StandardUnit.Milliseconds).withValue((double) System.currentTimeMillis() - startTime);
    metricBatcher.addDatum("AMM", latency);

    final MetricDatum success = newDatum(service, operation, startTime).withMetricName("Success")
            .withValue(exception == null ? 1.0 : 0.0).withUnit(StandardUnit.Count);
    metricBatcher.addDatum("AMM", success);
}

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

License:Apache License

void reportCounter(Map.Entry<String, ? extends Counting> entry, String type, List<MetricDatum> data) {
    Counting metric = entry.getValue();//from  w w w . jav a2s.c o m
    final long diff = diffLast(metric);
    if (diff == 0) {
        // Don't submit metrics that have not changed. No reason to keep these alive. Also saves on CloudWatch
        // costs.
        return;
    }

    DemuxedKey key = new DemuxedKey(entry.getKey());
    Iterables.addAll(data, key.newDatums(type, new Function<MetricDatum, MetricDatum>() {
        @Override
        public MetricDatum apply(MetricDatum datum) {
            return datum.withValue((double) diff).withUnit(StandardUnit.Count);
        }
    }));
}

From source file:com.github.lpezet.antiope.metrics.aws.MachineMetricFactory.java

License:Open Source License

private void addFileDescriptorMetrics(List<MetricDatum> pTargetList, Set<MachineMetric> pCustomSet) {
    JmxInfoProvider oProvider = JmxInfoProvider.Factory.getJmxInfoProvider();
    long[] oFdInfo = oProvider.getFileDecriptorInfo();

    if (oFdInfo != null) {
        long oOpenFdCount = oFdInfo[0];
        long oMaxFdCount = oFdInfo[1];
        List<Long> oValues = Arrays.asList(oOpenFdCount, oMaxFdCount - oOpenFdCount);
        MetricValues oMetricValues = fdMetricValues(pCustomSet, oValues);
        addMetrics(pTargetList, oMetricValues, StandardUnit.Count);
    }/*from   ww  w  .j  a v a  2  s.c om*/
}

From source file:com.github.lpezet.antiope.metrics.aws.MachineMetricFactory.java

License:Open Source License

private void addThreadMetrics(List<MetricDatum> pTargetList, Set<MachineMetric> pCustomSet) {
    long oThreadCount = mJmxInfoProvider.getThreadCount();
    long[] oIds = mJmxInfoProvider.findDeadlockedThreads();
    long oDeadLockThreadCount = oIds == null ? 0 : oIds.length;
    long oDaemonThreadCount = mJmxInfoProvider.getDaemonThreadCount();
    long oPeakThreadCount = mJmxInfoProvider.getPeakThreadCount();
    long oTotalStartedThreadCount = mJmxInfoProvider.getTotalStartedThreadCount();
    List<Long> oValues = Arrays.asList(oThreadCount, oDeadLockThreadCount, oDaemonThreadCount, oPeakThreadCount,
            oTotalStartedThreadCount);/*from   w  w w .ja  v  a 2s  .c o m*/
    MetricValues oMetricValues = threadMetricValues(pCustomSet, oValues);
    addMetrics(pTargetList, oMetricValues, StandardUnit.Count);
}

From source file:com.github.lpezet.antiope.metrics.aws.spi.PredefinedMetricTransformer.java

License:Open Source License

/**
 * Returns a list with a single metric datum for the specified retry or
 * request count predefined metric; or an empty list if there is none.
 * /*from  w  w  w .  j av  a 2s .  co  m*/
 * @param pMetricType
 *            must be either {@link Field#RequestCount} or
 *            {@link Field#RetryCount}; or else GIGO.
 */
protected List<MetricDatum> metricOfRequestOrRetryCount(APIRequestMetrics pMetricType, Request<?> pReq,
        Object pResp) {
    IMetrics m = pReq.getMetrics();
    TimingInfo ti = m.getTimingInfo();
    // Always retrieve the request count even for retry which is equivalent
    // to the number of requests minus one.
    Number oCounter = ti.getCounter(Field.RequestCount.name());
    if (oCounter == null) {
        // this is possible if one of the request handlers screwed up
        return Collections.emptyList();
    }
    int oRequestCount = oCounter.intValue();
    if (oRequestCount < 1) {
        LogFactory.getLog(getClass()).warn("request count must be at least one");
        return Collections.emptyList();
    }
    final double oCount = pMetricType == APIRequestMetrics.RequestCount ? oRequestCount : oRequestCount - 1 // retryCount = requestCount - 1
    ;
    if (oCount < 1) {
        return Collections.emptyList();
    } else {
        return Collections.singletonList(new MetricDatum().withMetricName(pReq.getServiceName())
                .withDimensions(
                        new Dimension().withName(Dimensions.MetricType.name()).withValue(pMetricType.name()))
                .withUnit(StandardUnit.Count).withValue(Double.valueOf(oCount))
                .withTimestamp(endTimestamp(ti)));
    }
}

From source file:com.github.lpezet.antiope.metrics.aws.spi.PredefinedMetricTransformer.java

License:Open Source License

protected List<MetricDatum> metricOfCount(APIRequestMetrics pMetricType, Request<?> pReq, Object pResp) {
    IMetrics m = pReq.getMetrics();//from ww  w  .  ja v a 2s .c  om
    TimingInfo ti = m.getTimingInfo();
    Number oCounter = ti.getCounter(pMetricType.name());
    if (oCounter == null) {
        return Collections.emptyList();
    }
    final double oCount = oCounter.doubleValue();
    if (oCount < 1) {
        return Collections.emptyList();
    } else {
        return Collections.singletonList(new MetricDatum().withMetricName(pReq.getServiceName())
                .withDimensions(
                        new Dimension().withName(Dimensions.MetricType.name()).withValue(pMetricType.name()))
                .withUnit(StandardUnit.Count).withValue(Double.valueOf(oCount))
                .withTimestamp(endTimestamp(ti)));
    }
}

From source file:com.github.lpezet.antiope.metrics.aws.spi.PredefinedMetricTransformer.java

License:Open Source License

/**
 * Returns a list of metric datum recorded for the specified counter metric
 * type; or an empty list if there is none.
 * //from  www.ja v a 2s . c o  m
 * @param pIncludesRequestType
 *            true iff an additional metric datum is to be created that
 *            includes the "request" dimension
 */
protected List<MetricDatum> counterMetricOf(MetricType pType, Request<?> pReq, Object pResp,
        boolean pIncludesRequestType) {
    IMetrics m = pReq.getMetrics();
    TimingInfo ti = m.getTimingInfo();
    final String oMetricName = pType.name();
    Number oCounter = ti.getCounter(oMetricName);
    if (oCounter == null) {
        return Collections.emptyList();
    }
    int oCount = oCounter.intValue();
    if (oCount < 1) {
        LogFactory.getLog(getClass()).warn("Count must be at least one");
        return Collections.emptyList();
    }
    final List<MetricDatum> oResult = new ArrayList<MetricDatum>();
    final Dimension oMetricDimension = new Dimension().withName(Dimensions.MetricType.name())
            .withValue(oMetricName);
    // non-request type specific metric datum
    final MetricDatum oFirst = new MetricDatum().withMetricName(pReq.getServiceName())
            .withDimensions(oMetricDimension).withUnit(StandardUnit.Count).withValue(Double.valueOf(oCount))
            .withTimestamp(endTimestamp(ti));
    oResult.add(oFirst);
    if (pIncludesRequestType) {
        // additional request type specific metric datum
        Dimension oRequestDimension = new Dimension().withName(Dimensions.RequestType.name())
                .withValue(requestType(pReq));
        final MetricDatum oSecond = newMetricDatum(oFirst, oMetricDimension, oRequestDimension);
        oResult.add(oSecond);
    }
    return oResult;
}

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

License:Apache License

void reportCounter(Map.Entry<String, ? extends Counting> entry, String typeDimValue, List<MetricDatum> data) {
    Counting metric = entry.getValue();/*from www .j  a va2s  . c  o  m*/
    final long diff = diffLast(metric);

    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.withValue((double) diff).withUnit(StandardUnit.Count);
        }
    }));
}

From source file:com.kurtraschke.nyctrtproxy.model.MatchMetrics.java

License:Apache License

private static MetricDatum metricCount(Date timestamp, String name, int value, Dimension dim) {
    return new MetricDatum().withMetricName(name).withTimestamp(timestamp).withValue((double) value)
            .withUnit(StandardUnit.Count).withDimensions(dim);
}