Class 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 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.
    • Constructor Detail

      • CloudWatchMetricConfig

        public CloudWatchMetricConfig()
    • 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.
      • 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.
      • 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