private List<MetricDatum> toMetricData0(MetricType metricType,
            Request<?> req, Response<?> response) throws SecurityException,
            NoSuchMethodException, IllegalAccessException,
            InvocationTargetException {
        if (!(metricType instanceof DynamoDBRequestMetric))
            return null;
        // Predefined metrics across all aws http clients
        DynamoDBRequestMetric predefined = (DynamoDBRequestMetric) metricType;
        switch(predefined) {
            case DynamoDBConsumedCapacity:
                if (response == null)
                    return Collections.emptyList();
                Object awsResponse = response.getAwsResponse();
                Method method = awsResponse.getClass().getMethod("getConsumedCapacity");
                Object value = method.invoke(awsResponse);
                if (!(value instanceof ConsumedCapacity))
                    return Collections.emptyList();
                ConsumedCapacity consumedCapacity = (ConsumedCapacity) value;
                Double units = consumedCapacity.getCapacityUnits();
                if (units == null)
                    return Collections.emptyList();
                String tableName = consumedCapacity.getTableName();
                List<Dimension> dims = new ArrayList<Dimension>();
                dims.add(new Dimension()
                        .withName(Dimensions.MetricType.name())
                        .withValue(metricType.name()));
                // request type specific
                dims.add(new Dimension()
                        .withName(Dimensions.RequestType.name())
                        .withValue(requestType(req)));
                // table specific
                dims.add(new Dimension()
                        .withName(DynamoDBDimensions.TableName.name())
                        .withValue(tableName));
                MetricDatum datum = new MetricDatum()
                    .withMetricName(req.getServiceName())
                    .withDimensions(dims)
                    .withUnit(StandardUnit.Count)
                    .withValue(units);
                return Collections.singletonList(datum);
            default:
                return Collections.emptyList();
        }
    }
An internal service provider implementation for an DyanmoDB specific request
metric transformer.

This class is loaded only if there are Amazon DyanmoDB specific predefined
metrics to be processed.

@see AWSMetricTransformerFactory
aws-java-sdk-cloudwatchmetrics/src/main/java/com/amazonaws/metrics/internal/cloudwatch/provider/transform/DynamoDBRequestMetricTransformer.java