Class CloudWatchMetricConfig
- java.lang.Object
-
- com.amazonaws.metrics.internal.cloudwatch.CloudWatchMetricConfig
-
public class CloudWatchMetricConfig extends Object
Configuration for the default AWS SDK collection implementation. This class is not intended to be used directly by client code except for cases where the default behavior of the internal Amazon CloudWatch collector implementation needs to be customized.Example:
/** * My custom Request Metric Collector by extending from the internal Amazon CloudWatch * implementation. */ static class MyCloudWatchMetricCollector extends CloudWatchRequestMetricCollector { MyCloudWatchMetricCollector(CloudWatchMetricConfig config) { super(config); } } MyCloudWatchMetricCollector myCollector = new MyCloudWatchMetricCollector( new CloudWatchMetricConfig() .withQueuePollTimeoutMilli(60000) .withMetricQueueSize(1000) .withCredentialsProvider( new DefaultAWSCredentialsProviderChain()) .withCloudWatchEndPoint("monitoring.us-west-2.amazonaws.com") .withPredefinedMetrics( new HashSet<Field>(Arrays.asList(Field.HttpRequestTime, Field.ResponseProcessingTime)))); myCollector.start(); // Enable the AWS SDK level request metric collection with a custom collector AwsSdkMetrics.setRequestMetricCollector(myCollector);
- See Also:
AwsSdkMetrics
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_METRICS_QSIZE
Default metrics queue size.static int
DEFAULT_QUEUE_POLL_TIMEOUT_MILLI
Default timeout in millisecond for queue polling.
-
Constructor Summary
Constructors Constructor Description CloudWatchMetricConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getCloudWatchEndPoint()
Returns the end point of AmazonCloudWatch to upload the metrics.AWSCredentialsProvider
getCredentialsProvider()
Returns the credential provider that holds the credentials to connect to Amazon CloudWatch.int
getMetricQueueSize()
long
getQueuePollTimeoutMilli()
Returns the metrics queue polling timeout in millisecond.void
setCloudWatchEndPoint(String cloudWatchEndPoint)
Sets the end point of AmazonCloudWatch to upload the metrics.void
setCredentialsProvider(AWSCredentialsProvider credentialsProvider)
Sets the credential provider to the given provider.void
setMetricQueueSize(int metricQueueSize)
Configure the metric queue size, overriding the default.void
setQueuePollTimeoutMilli(long queuePollTimeoutMilli)
Sets the metric queue polling timeout in millisecond.CloudWatchMetricConfig
withCloudWatchEndPoint(String cloudWatchEndPoint)
CloudWatchMetricConfig
withCredentialsProvider(AWSCredentialsProvider credentialsProvider)
CloudWatchMetricConfig
withMetricQueueSize(int metricQueueSize)
CloudWatchMetricConfig
withQueuePollTimeoutMilli(long queuePollTimeoutMilli)
-
-
-
Field Detail
-
DEFAULT_METRICS_QSIZE
public static final int DEFAULT_METRICS_QSIZE
Default metrics queue size. If the queue size exceeds this value, then excessive metrics will be dropped to prevent resource exhaustion.- See Also:
- Constant Field Values
-
DEFAULT_QUEUE_POLL_TIMEOUT_MILLI
public static final int DEFAULT_QUEUE_POLL_TIMEOUT_MILLI
Default timeout in millisecond for queue polling. Set to one-minute which is the finest granularity of Amazon CloudWatch.
-
-
Method Detail
-
getCredentialsProvider
public AWSCredentialsProvider getCredentialsProvider()
Returns the credential provider that holds the credentials to connect to Amazon CloudWatch.
-
setCredentialsProvider
public void setCredentialsProvider(AWSCredentialsProvider credentialsProvider)
Sets the credential provider to the given provider. This credential provider is used by the uploader thread to connect to Amazon CloudWatch.
-
withCredentialsProvider
public CloudWatchMetricConfig withCredentialsProvider(AWSCredentialsProvider credentialsProvider)
-
getQueuePollTimeoutMilli
public long getQueuePollTimeoutMilli()
Returns the metrics queue polling timeout in millisecond.
-
setQueuePollTimeoutMilli
public void setQueuePollTimeoutMilli(long queuePollTimeoutMilli)
Sets the metric queue polling timeout in millisecond. The default set set to one-minute per the finest granularity of Amazon CloudWatch
-
withQueuePollTimeoutMilli
public CloudWatchMetricConfig withQueuePollTimeoutMilli(long queuePollTimeoutMilli)
-
getCloudWatchEndPoint
public String getCloudWatchEndPoint()
Returns the end point of AmazonCloudWatch to upload the metrics.
-
setCloudWatchEndPoint
public void setCloudWatchEndPoint(String cloudWatchEndPoint)
Sets the end point of AmazonCloudWatch to upload the metrics.
-
withCloudWatchEndPoint
public CloudWatchMetricConfig withCloudWatchEndPoint(String cloudWatchEndPoint)
-
getMetricQueueSize
public int getMetricQueueSize()
-
setMetricQueueSize
public void setMetricQueueSize(int metricQueueSize)
Configure the metric queue size, overriding the default. Must be at least 1.- See Also:
DEFAULT_METRICS_QSIZE
-
withMetricQueueSize
public CloudWatchMetricConfig withMetricQueueSize(int metricQueueSize)
-
-