Example usage for com.amazonaws.util TimingInfo getSubMeasurement

List of usage examples for com.amazonaws.util TimingInfo getSubMeasurement

Introduction

In this page you can find the example usage for com.amazonaws.util TimingInfo getSubMeasurement.

Prototype

public TimingInfo getSubMeasurement(String subMeasurementName) 

Source Link

Usage

From source file:com.facebook.presto.hive.PrestoS3FileSystemMetricCollector.java

License:Apache License

@Override
public void collectMetrics(Request<?> request, Response<?> response) {
    AWSRequestMetrics metrics = request.getAWSRequestMetrics();

    TimingInfo timingInfo = metrics.getTimingInfo();
    Number requestCounts = timingInfo.getCounter(RequestCount.name());
    Number retryCounts = timingInfo.getCounter(HttpClientRetryCount.name());
    Number throttleExceptions = timingInfo.getCounter(ThrottleException.name());
    TimingInfo requestTime = timingInfo.getSubMeasurement(HttpRequestTime.name());
    TimingInfo clientExecuteTime = timingInfo.getSubMeasurement(ClientExecuteTime.name());

    if (requestCounts != null) {
        stats.updateAwsRequestCount(requestCounts.longValue());
    }//  ww  w  . ja va 2  s .  c  o  m

    if (retryCounts != null) {
        stats.updateAwsRetryCount(retryCounts.longValue());
    }

    if (throttleExceptions != null) {
        stats.updateAwsThrottleExceptionsCount(throttleExceptions.longValue());
    }

    if (requestTime != null && requestTime.getTimeTakenMillisIfKnown() != null) {
        stats.addAwsRequestTime(new Duration(requestTime.getTimeTakenMillisIfKnown(), MILLISECONDS));
    }

    if (clientExecuteTime != null && clientExecuteTime.getTimeTakenMillisIfKnown() != null) {
        stats.addAwsClientExecuteTime(
                new Duration(clientExecuteTime.getTimeTakenMillisIfKnown(), MILLISECONDS));
    }
}