Example usage for com.amazonaws.services.cloudwatch.model PutMetricDataRequest getNamespace

List of usage examples for com.amazonaws.services.cloudwatch.model PutMetricDataRequest getNamespace

Introduction

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

Prototype


public String getNamespace() 

Source Link

Document

The namespace for the metric data.

Usage

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

License:Apache License

protected void sendBatch(Map<String, Collection<MetricDatum>> datums) {
    for (final Map.Entry<String, Collection<MetricDatum>> e : datums.entrySet()) {
        for (final List<MetricDatum> batch : Lists.partition(Lists.newLinkedList(e.getValue()), BATCH_SIZE)) {
            cloudWatch.putMetricDataAsync(
                    new PutMetricDataRequest().withNamespace(e.getKey()).withMetricData(batch),
                    new AsyncHandler<PutMetricDataRequest, Void>() {

                        @Override
                        public void onError(Exception exception) {
                            LOG.error("PutMetricData failed", exception);
                            LOG.info("Requeueing metric data.");
                            queuedDatums.putAll(e.getKey(), batch);
                        }/*from w  w w .  j  ava2  s  . c  o  m*/

                        @Override
                        public void onSuccess(PutMetricDataRequest request, Void result) {
                            LOG.info("Successfully put " + request.getMetricData().size()
                                    + " datums for namespace " + request.getNamespace());
                            LOG.debug("Request", request);
                        }

                    });
        }
    }
}

From source file:io.micrometer.cloudwatch.CloudWatchMeterRegistry.java

License:Apache License

private void sendMetricData(List<MetricDatum> metricData) {
    PutMetricDataRequest putMetricDataRequest = new PutMetricDataRequest().withNamespace(config.namespace())
            .withMetricData(metricData);
    amazonCloudWatchAsync.putMetricDataAsync(putMetricDataRequest,
            new AsyncHandler<PutMetricDataRequest, PutMetricDataResult>() {
                @Override//from   w w  w .j  a va 2 s.  com
                public void onError(Exception exception) {
                    logger.error("Error sending metric data.", exception);
                }

                @Override
                public void onSuccess(PutMetricDataRequest request, PutMetricDataResult result) {
                    logger.debug("Published metric with namespace:{}", request.getNamespace());
                }
            });
}

From source file:org.apache.nifi.processors.aws.cloudwatch.MockPutCloudWatchMetric.java

License:Apache License

protected PutMetricDataResult putMetricData(PutMetricDataRequest metricDataRequest)
        throws AmazonClientException {
    putMetricDataCallCount++;/*from   w ww.  ja v  a 2 s  . c  o  m*/
    actualNamespace = metricDataRequest.getNamespace();
    actualMetricData = metricDataRequest.getMetricData();

    if (throwException != null) {
        throw throwException;
    }

    return result;
}