Java 类com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync 实例源码

项目:micrometer    文件:CloudWatchExportConfiguration.java   
@Bean
@ConditionalOnMissingBean(AmazonCloudWatchAsyncClient.class)
public AmazonCloudWatchAsync amazonCloudWatchAsync(AWSCredentialsProvider credentialsProvider) {
    return AmazonCloudWatchAsyncClientBuilder.standard()
        .withCredentials(credentialsProvider)
        .build();
}
项目:micrometer    文件:CloudWatchMeterRegistry.java   
public CloudWatchMeterRegistry(CloudWatchConfig config, Clock clock,
                               AmazonCloudWatchAsync amazonCloudWatchAsync, ThreadFactory threadFactory) {
    super(config, clock);
    this.amazonCloudWatchAsync = amazonCloudWatchAsync;
    this.config = config;
    this.config().namingConvention(NamingConvention.identity);
    start(threadFactory);
}
项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:Main.java   
ReportingApp() {
    this.metricRegistry = new MetricRegistry();
    this.theTimer = metricRegistry.timer("TheTimer");

    final AmazonCloudWatchAsync amazonCloudWatchAsync =
            AmazonCloudWatchAsyncClientBuilder
                    .standard()
                    .withRegion(Regions.US_WEST_2)
                    .build();

    final CloudWatchReporter cloudWatchReporter =
            CloudWatchReporter.forRegistry(metricRegistry, amazonCloudWatchAsync, Main.class.getName())
                    .convertRatesTo(TimeUnit.SECONDS)
                    .convertDurationsTo(TimeUnit.MILLISECONDS)
                    .filter(MetricFilter.ALL)
                    .withPercentiles(Percentile.P75, Percentile.P99)
                    .withOneMinuteMeanRate()
                    .withFiveMinuteMeanRate()
                    .withFifteenMinuteMeanRate()
                    .withMeanRate()
                    .withArithmeticMean()
                    .withStdDev()
                    .withStatisticSet()
                    .withJvmMetrics()
                    .withGlobalDimensions("Region=us-west-2", "Instance=stage")
                    .withDryRun()
                    .build();

    cloudWatchReporter.start(10, TimeUnit.SECONDS);
}
项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:CloudWatchReporter.java   
private Builder(final MetricRegistry metricRegistry, final AmazonCloudWatchAsync cloudWatchAsyncClient, final String namespace) {
    this.metricRegistry = metricRegistry;
    this.cloudWatchAsyncClient = cloudWatchAsyncClient;
    this.namespace = namespace;
    this.percentiles = new Percentile[]{Percentile.P75, Percentile.P95, Percentile.P999};
    this.metricFilter = MetricFilter.ALL;
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.globalDimensions = new LinkedHashSet<>();
    this.cwRateUnit = toStandardUnit(rateUnit);
    this.cwDurationUnit = toStandardUnit(durationUnit);
    this.clock = Clock.defaultClock();
}
项目:metrics-cloudwatch    文件:CloudWatchReporter.java   
/**
 * Creates a new {@link ScheduledReporter} instance. The reporter does not report metrics until
 * {@link #start(long, TimeUnit)}.
 *
 * @param registry        the {@link MetricRegistry} containing the metrics this reporter will report
 * @param metricNamespace (optional) CloudWatch metric namespace that all metrics reported by this reporter will
 *                        fall under
 * @param metricFilter    (optional) see {@link MetricFilter}
 * @param cloudWatch      client
 */
public CloudWatchReporter(MetricRegistry registry,
                          String metricNamespace,
                          MetricFilter metricFilter,
                          AmazonCloudWatchAsync cloudWatch) {

    super(registry, "CloudWatchReporter:" + metricNamespace, metricFilter, TimeUnit.MINUTES, TimeUnit.MINUTES);

    this.metricNamespace = metricNamespace;
    this.cloudWatch = cloudWatch;
}
项目:micrometer    文件:CloudWatchExportConfiguration.java   
@Bean
@ConditionalOnProperty(value = "management.metrics.export.cloudwatch.enabled", matchIfMissing = true)
public MetricsExporter cloudwatchExporter(CloudWatchConfig config, Clock clock, AmazonCloudWatchAsync client) {
    return () -> new CloudWatchMeterRegistry(config, clock, client);
}
项目:micrometer    文件:CloudWatchMeterRegistry.java   
public CloudWatchMeterRegistry(CloudWatchConfig config, Clock clock,
                           AmazonCloudWatchAsync amazonCloudWatchAsync) {
    this(config, clock, amazonCloudWatchAsync, Executors.defaultThreadFactory());
}
项目:amediamanager    文件:MetricBatcher.java   
@Autowired
public MetricBatcher(AmazonCloudWatchAsync cloudWatch) {
    super(cloudWatch);
}
项目:amediamanager    文件:MetricBatcher.java   
public MetricBatcher(AmazonCloudWatchAsync cloudWatch) {
    this.cloudWatch = cloudWatch;
}
项目:dropwizard-metrics-cloudwatch    文件:CloudWatchMachineDimensionReporter.java   
public CloudWatchMachineDimensionReporter(MetricRegistry registry, String metricNamespace, List<String> dimensions,
                                          MetricFilter metricFilter, AmazonCloudWatchAsync cloudWatch) {

    super(registry, metricNamespace, metricFilter, cloudWatch);
    this.dimensions = dimensions;
}
项目:dropwizard-metrics-cloudwatch    文件:CloudWatchReporterFactory.java   
@JsonIgnore
public void setClient(AmazonCloudWatchAsync client) {
    this.client = client;
}
项目:dropwizard-metrics-cloudwatch    文件:CloudWatchReporterFactoryTest.java   
@Test
public void verifySendingToCloudWatch() throws Exception {
    CloudWatchReporterFactory factory = new CloudWatchReporterFactory();

    MetricRegistry registry = new MetricRegistry();
    Counter counter = registry.counter(MetricRegistry.name(this.getClass(), "test machine=123*"));


    AmazonCloudWatchAsync mockClient = mock(AmazonCloudWatchAsync.class);

    final Future<Void> mockFuture = mock(Future.class);
    when(mockClient.putMetricDataAsync(any(PutMetricDataRequest.class))).thenReturn(mockFuture);
    when(mockClient.putMetricDataAsync(any(PutMetricDataRequest.class))).thenAnswer(new Answer<Future>() {
        @Override
        public Future answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();

            if (args.length > 0 && args[0] != null) {
                PutMetricDataRequest req = (PutMetricDataRequest) args[0];
                assertEquals(req.getNamespace(), "myspace");
                for (MetricDatum datum : req.getMetricData()) {
                    System.out.println(datum.toString());
                    assertTrue(datum.toString().contains("env"));
                }
            }

            return mockFuture;
        }
    });

    factory.setClient(mockClient);
    factory.setAwsAccessKeyId("fakeKey");
    factory.setAwsSecretKey("fakeSecret");
    factory.setNamespace("myspace");
    factory.setGlobalDimensions(Lists.newArrayList("env=dev"));
    ScheduledReporter reporter = factory.build(registry);

    for (int i = 0; i < 200; i++) {
        counter.inc();
    }
    reporter.report();
    verify(mockClient.putMetricDataAsync(any(PutMetricDataRequest.class)), times(1));
}
项目:metrics-cloudwatch    文件:CloudWatchReporterBuilder.java   
/**
 * @param client CloudWatch client
 * @return this (for chaining)
 */
public CloudWatchReporterBuilder withClient(AmazonCloudWatchAsync client) {
    this.client = client;
    return this;
}
项目:metrics-cloudwatch    文件:CloudWatchReporterBuilder.java   
/**
 * @return a new CloudWatchReporter instance based on the state of this builder
 */
public CloudWatchReporter build() {
    Preconditions.checkState(!Strings.isNullOrEmpty(namespace), "Metric namespace is required.");

    String resolvedNamespace = namespace;

    // Use specified or fall back to default. Don't secretly modify the fields of this builder
    // in case the caller wants to re-use it to build other reporters, or something.

    MetricRegistry resolvedRegistry = null != registry ? registry : new MetricRegistry();
    MetricFilter resolvedFilter = null != filter ? filter : MetricFilter.ALL;
    AmazonCloudWatchAsync resolvedCloudWatchClient = null != client ? client : new AmazonCloudWatchAsyncClient();
    String resolvedDimensions = null != dimensions ? dimensions : null;
    Boolean resolvedTimestampLocal = null != timestampLocal ? timestampLocal : false;

    String resolvedTypeDimName = null != typeDimName ? typeDimName : Constants.DEF_DIM_NAME_TYPE;
    String resolvedTypeDimValGauge = null != typeDimValGauge ? typeDimValGauge : Constants.DEF_DIM_VAL_GAUGE;
    String resolvedTypeDimValCounterCount = null != typeDimValCounterCount ? typeDimValCounterCount : Constants.DEF_DIM_VAL_COUNTER_COUNT;
    String resolvedTypeDimValMeterCount = null != typeDimValMeterCount ? typeDimValMeterCount : Constants.DEF_DIM_VAL_METER_COUNT;
    String resolvedTypeDimValHistoSamples = null != typeDimValHistoSamples ? typeDimValHistoSamples : Constants.DEF_DIM_VAL_HISTO_SAMPLES;
    String resolvedTypeDimValHistoStats = null != typeDimValHistoStats ? typeDimValHistoStats : Constants.DEF_DIM_VAL_HISTO_STATS;
    String resolvedTypeDimValTimerSamples = null != typeDimValTimerSamples ? typeDimValTimerSamples : Constants.DEF_DIM_VAL_TIMER_SAMPLES;
    String resolvedTypeDimValTimerStats = null != typeDimValTimerStats ? typeDimValTimerStats : Constants.DEF_DIM_VAL_TIMER_STATS;

    Predicate<MetricDatum> resolvedReporterFilter = null != reporterFilter ? reporterFilter : Predicates.<MetricDatum>alwaysTrue();

    return new CloudWatchReporter(
            resolvedRegistry,
            resolvedNamespace,
            resolvedFilter,
            resolvedCloudWatchClient)
            .withDimensions(resolvedDimensions)
            .withTimestampLocal(resolvedTimestampLocal)
            .withTypeDimName(resolvedTypeDimName)
            .withTypeDimValGauge(resolvedTypeDimValGauge)
            .withTypeDimValCounterCount(resolvedTypeDimValCounterCount)
            .withTypeDimValMeterCount(resolvedTypeDimValMeterCount)
            .withTypeDimValHistoSamples(resolvedTypeDimValHistoSamples)
            .withTypeDimValHistoStats(resolvedTypeDimValHistoStats)
            .withTypeDimValTimerSamples(resolvedTypeDimValTimerSamples)
            .withTypeDimValTimerStats(resolvedTypeDimValTimerStats)
            .withReporterFilter(resolvedReporterFilter);
}
项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:CloudWatchReporter.java   
/**
 * Creates a new {@link Builder} that sends values from the given {@link MetricRegistry} to the given namespace
 * using the given CloudWatch client.
 *
 * @param metricRegistry {@link MetricRegistry} instance
 * @param client         {@link AmazonCloudWatchAsync} instance
 * @param namespace      the namespace. Must be non-null and not empty.
 * @return {@link Builder} instance
 */
public static Builder forRegistry(final MetricRegistry metricRegistry, final AmazonCloudWatchAsync client, final String namespace) {
    return new Builder(metricRegistry, client, namespace);
}
项目:metrics-cloudwatch    文件:CloudWatchReporter.java   
/**
 * Creates a new {@link ScheduledReporter} instance. The reporter does not report metrics until
 * {@link #start(long, TimeUnit)}.
 *
 * @param registry   the {@link MetricRegistry} containing the metrics this reporter will report
 * @param cloudWatch client
 */
public CloudWatchReporter(MetricRegistry registry, AmazonCloudWatchAsync cloudWatch) {
    this(registry, null, cloudWatch);
}
项目:metrics-cloudwatch    文件:CloudWatchReporter.java   
/**
 * Creates a new {@link ScheduledReporter} instance. The reporter does not report metrics until
 * {@link #start(long, TimeUnit)}.
 *
 * @param registry        the {@link MetricRegistry} containing the metrics this reporter will report
 * @param metricNamespace (optional) CloudWatch metric namespace that all metrics reported by this reporter will
 *                        fall under
 * @param cloudWatch      client
 */
public CloudWatchReporter(MetricRegistry registry,
                          String metricNamespace,
                          AmazonCloudWatchAsync cloudWatch) {
    this(registry, metricNamespace, MetricFilter.ALL, cloudWatch);
}