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.spi;
Internal SPI used to provide custom request metric transformer that can be added to or override the default AWS SDK implementation. Implementation of this interface should ensure the java.lang.Object.equals(java.lang.Object) and java.lang.Object.hashCode() methods are overridden as necessary.
public interface RequestMetricTransformer {
Returns a list of metric datum for the metrics collected for the given request/response, or null if this transformer does not recognize the specific input metric type.

Note returning an empty list means the transformer recognized the metric type but concluded there is no metrics to be generated for it.

metricType the predefined metric type
    public List<MetricDatumtoMetricData(MetricType metricType,
            Request<?> requestResponse<?> response);
A convenient instance of a no-op request metric transformer.
    public static final RequestMetricTransformer NONE = new RequestMetricTransformer() {
        public List<MetricDatumtoMetricData(MetricType requestMetric,
                Request<?> requestResponse<?> response) {
            return null;

Common utilities for implementing this SPI.
    public static enum Utils {
        public static long endTimeMilli(TimingInfo ti) {
            Long endTimeMilli = ti.getEndEpochTimeMilliIfKnown();
            return endTimeMilli == null ? System.currentTimeMillis() : endTimeMilli.longValue();
        public static Date endTimestamp(TimingInfo ti) {
            return new Date(endTimeMilli(ti));
New to GrepCode? Check out our FAQ X