当前位置: 首页>>代码示例>>Java>>正文


Java PutMetricDataRequest.getMetricData方法代码示例

本文整理汇总了Java中com.amazonaws.services.cloudwatch.model.PutMetricDataRequest.getMetricData方法的典型用法代码示例。如果您正苦于以下问题:Java PutMetricDataRequest.getMetricData方法的具体用法?Java PutMetricDataRequest.getMetricData怎么用?Java PutMetricDataRequest.getMetricData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.cloudwatch.model.PutMetricDataRequest的用法示例。


在下文中一共展示了PutMetricDataRequest.getMetricData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reportMetersCountersGaugesWithZeroValuesOnlyWhenConfigured

import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest; //导入方法依赖的package包/类
@Test
public void reportMetersCountersGaugesWithZeroValuesOnlyWhenConfigured() throws Exception {
    metricRegistry.register(ARBITRARY_GAUGE_NAME, (Gauge<Long>) () -> 0L);
    metricRegistry.meter(ARBITRARY_METER_NAME).mark(0);
    metricRegistry.counter(ARBITRARY_COUNTER_NAME).inc(0);
    metricRegistry.timer(ARBITRARY_TIMER_NAME).update(-1L, TimeUnit.NANOSECONDS);

    buildReportWithSleep(reporterBuilder
            .withArithmeticMean()
            .withOneMinuteMeanRate()
            .withFiveMinuteMeanRate()
            .withFifteenMinuteMeanRate()
            .withZeroValuesSubmission()
            .withMeanRate());

    verify(mockAmazonCloudWatchAsyncClient, times(1)).putMetricDataAsync(metricDataRequestCaptor.capture());

    final PutMetricDataRequest putMetricDataRequest = metricDataRequestCaptor.getValue();
    final List<MetricDatum> metricData = putMetricDataRequest.getMetricData();
    for (final MetricDatum metricDatum : metricData) {
        assertThat(metricDatum.getValue()).isEqualTo(0.0);
    }
}
 
开发者ID:azagniotov,项目名称:codahale-aggregated-metrics-cloudwatch-reporter,代码行数:24,代码来源:CloudWatchReporterTest.java

示例2: metricDatumByDimensionFromCapturedRequest

import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest; //导入方法依赖的package包/类
private MetricDatum metricDatumByDimensionFromCapturedRequest(final String dimensionValue) {
    final PutMetricDataRequest putMetricDataRequest = metricDataRequestCaptor.getValue();
    final List<MetricDatum> metricData = putMetricDataRequest.getMetricData();

    final Optional<MetricDatum> metricDatumOptional =
            metricData
                    .stream()
                    .filter(metricDatum -> metricDatum.getDimensions()
                            .contains(new Dimension().withName(DIMENSION_NAME_TYPE).withValue(dimensionValue)))
                    .findFirst();

    if (metricDatumOptional.isPresent()) {
        return metricDatumOptional.get();
    }

    throw new IllegalStateException("Could not find MetricDatum for Dimension value: " + dimensionValue);
}
 
开发者ID:azagniotov,项目名称:codahale-aggregated-metrics-cloudwatch-reporter,代码行数:18,代码来源:CloudWatchReporterTest.java

示例3: allDimensionsFromCapturedRequest

import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest; //导入方法依赖的package包/类
private List<Dimension> allDimensionsFromCapturedRequest() {
    final PutMetricDataRequest putMetricDataRequest = metricDataRequestCaptor.getValue();
    final List<MetricDatum> metricData = putMetricDataRequest.getMetricData();
    final List<Dimension> all = new LinkedList<>();
    for (final MetricDatum metricDatum : metricData) {
        all.addAll(metricDatum.getDimensions());
    }
    return all;
}
 
开发者ID:azagniotov,项目名称:codahale-aggregated-metrics-cloudwatch-reporter,代码行数:10,代码来源:CloudWatchReporterTest.java

示例4: report

import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest; //导入方法依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public void report(
        SortedMap<String, Gauge> gauges,
        SortedMap<String, Counter> counters,
        SortedMap<String, Histogram> histograms,
        SortedMap<String, Meter> meters,
        SortedMap<String, Timer> timers) {

    logger.info("Starting metrics publishing to AWS CloudWatch.");

    LinkedList<PutMetricDataRequest> requests = new LinkedList<>();

    addMetricData(gauges, counters, histograms, meters, timers, requests, new Date());

    if (requests.isEmpty()) {
        logger.debug("No metric data to send to AWS.");
        return;
    }

    for (PutMetricDataRequest request : requests) {
        try {
            for (MetricDatum datum : request.getMetricData()) {
                logger.debug("Sending metric " + datum);
            }
            cloudWatch.putMetricData(request);
        } catch (Exception e) {
            logger.error("Failed to log metrics to CloudWatch discarding metrics for this attempt...",e);
            return;
        }
    }
    logger.info("Finished metrics publishing to AWS CloudWatch.");
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:34,代码来源:MetricsCloudWatchReporter.java


注:本文中的com.amazonaws.services.cloudwatch.model.PutMetricDataRequest.getMetricData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。