Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Update to using AmazonCloudWatch client (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
stlava authored and diranged committed May 24, 2018
1 parent 73d4331 commit 5237bc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Expand Up @@ -23,8 +23,7 @@
import java.util.stream.Collectors;

import org.apache.commons.collections4.ListUtils;

import com.amazonaws.services.cloudwatch.AmazonCloudWatchClient;
import com.amazonaws.services.cloudwatch.AmazonCloudWatch;
import com.amazonaws.services.cloudwatch.model.Dimension;
import com.amazonaws.services.cloudwatch.model.MetricDatum;
import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest;
Expand All @@ -38,11 +37,11 @@
* Writes metrics to Amazon Cloudwatch.
*/
public class CloudwatchReporter implements Reporter {
private final AmazonCloudWatchClient client;
private final AmazonCloudWatch client;
private final String namespace;
private final List<StatFilter> statFilters;

public CloudwatchReporter(AmazonCloudWatchClient client, final String namespace,
public CloudwatchReporter(AmazonCloudWatch client, final String namespace,
final List<StatFilter> statFilters) {
this.client = client;
this.namespace = namespace;
Expand Down
Expand Up @@ -15,7 +15,8 @@

package com.nextdoor.bender.monitoring.cw;

import com.amazonaws.services.cloudwatch.AmazonCloudWatchClient;
import com.amazonaws.services.cloudwatch.AmazonCloudWatch;
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder;
import com.nextdoor.bender.config.AbstractConfig;
import com.nextdoor.bender.monitoring.ReporterFactory;

Expand All @@ -24,16 +25,18 @@
*/
public class CloudwatchReporterFactory implements ReporterFactory {
private CloudwatchReporterConfig config;
private AmazonCloudWatchClient client;
private AmazonCloudWatch client;

@Override
public void setConf(AbstractConfig config) {
this.config = (CloudwatchReporterConfig) config;
this.client = new AmazonCloudWatchClient();
AmazonCloudWatchClientBuilder clientBuilder = AmazonCloudWatchClientBuilder.standard();

if (this.config.getRegion() != null) {
this.client = this.client.withRegion(this.config.getRegion());
clientBuilder.withRegion(this.config.getRegion());
}

this.client = clientBuilder.build();
}

@Override
Expand Down

0 comments on commit 5237bc6

Please sign in to comment.