Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright 2010-2015, Inc. or its affiliates. All Rights Reserved.
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
  * or in the "license" file accompanying this file. This file is distributed
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
 package com.amazonaws.metrics.internal.cloudwatch;
This is the default implementation of an AWS SDK request metric collection system.

     protected final static Log log = LogFactory.getLog(RequestMetricCollectorSupport.class);
     private final BlockingQueue<MetricDatumqueue;
         this. = queue;

Collects the metrics at the end of a request/response cycle, transforms the metric data points into a cloud watch metric datum representation, and then adds it to a memory queue so it will get summarized into the necessary statistics and uploaded to Amazon CloudWatch.
     public void collectMetrics(Request<?> requestResponse<?> response) {
         try {
         } catch(Exception ex) { // defensive code
             if (.isDebugEnabled()) {
                 .debug("Ignoring unexpected failure"ex);
     private void collectMetrics0(Request<?> requestResponse<?> response) {
         AWSRequestMetrics arm = request.getAWSRequestMetrics();
         if (arm == null || !arm.isEnabled()) {
         for (MetricType type: AwsSdkMetrics.getPredefinedMetrics()) {
             if (!(type instanceof RequestMetricType))
             PredefinedMetricTransformer transformer = getTransformer();
             for (MetricDatum datum : transformer.toMetricData(typerequestresponse)) {
                 try {
                     if (!addMetricsToQueue(datum)) {
                         if (.isDebugEnabled()) {
                             .debug("Failed to add to the metrics queue (due to no space available) for "
                                     + ":"
                                     + request.getServiceName());
                 } catch(RuntimeException ex) {
                     .warn("Failed to add to the metrics queue for "
                         + + ":" + request.getServiceName(),

Adds the given metric to the queue, returning true if successful or false if no space available.
     protected boolean addMetricsToQueue(MetricDatum metric) {
         return .offer(metric); 
Returns the predefined metrics transformer.
    protected PredefinedMetricTransformer getTransformer() { return ; }
New to GrepCode? Check out our FAQ X