@@ -60,49 +60,69 @@ public AwsStatisticsCollector(final StatisticsFromAwsSdk collector) {
6060 /**
6161 * This is the callback from the AWS SDK where metrics
6262 * can be collected.
63- * @param request AWS request
64- * @param response AWS response
63+ * @param metricCollection metrics collection
6564 */
6665 @ Override
6766 public void publish (MetricCollection metricCollection ) {
67+ // MetricCollections are nested, so we need to traverse through their
68+ // "children" to collect the desired metrics. E.g.:
69+ //
70+ // ApiCall
71+ // ┌─────────────────────────────────────────┐
72+ // │ MarshallingDuration=PT0.002808333S │
73+ // │ RetryCount=0 │
74+ // │ ApiCallSuccessful=true │
75+ // │ OperationName=DeleteObject │
76+ // │ ApiCallDuration=PT0.079801458S │
77+ // │ CredentialsFetchDuration=PT0.000007083S │
78+ // │ ServiceId=S3 │
79+ // └─────────────────────────────────────────┘
80+ // ApiCallAttempt
81+ // ┌─────────────────────────────────────────────────────────────────┐
82+ // │ SigningDuration=PT0.000319375S │
83+ // │ ServiceCallDuration=PT0.078908584S │
84+ // │ AwsExtendedRequestId=Kmvb2Sz8NuDgIFJPKzLLBhuHgQGmpAjVYBMrSHDvy= │
85+ // │ HttpStatusCode=204 │
86+ // │ BackoffDelayDuration=PT0S │
87+ // │ AwsRequestId=KR0XZCSX │
88+ // └─────────────────────────────────────────────────────────────────┘
89+ // HttpClient
90+ // ┌─────────────────────────────────┐
91+ // │ AvailableConcurrency=1 │
92+ // │ LeasedConcurrency=0 │
93+ // │ ConcurrencyAcquireDuration=PT0S │
94+ // │ PendingConcurrencyAcquires=0 │
95+ // │ MaxConcurrency=96 │
96+ // │ HttpClientName=Apache │
97+ // └─────────────────────────────────┘
98+
6899 final long [] throttling = {0 };
69100 recurseThroughChildren (metricCollection )
70101 .collect (Collectors .toList ())
71102 .forEach (m -> {
72103 counter (m , CoreMetric .RETRY_COUNT , retries -> {
73- // Replaces com.amazonaws.util.AWSRequestMetrics.Field.HttpClientRetryCount
74104 collector .updateAwsRetryCount (retries );
75-
76- // Replaces com.amazonaws.util.AWSRequestMetrics.Field.RequestCount (always HttpClientRetryCount+1)
77105 collector .updateAwsRequestCount (retries + 1 );
78106 });
79107
80- // TODO: confirm replacement
81- // Replaces com.amazonaws.util.AWSRequestMetrics.Field.ThrottleException
82108 counter (m , HttpMetric .HTTP_STATUS_CODE , statusCode -> {
83109 if (statusCode == HttpStatusCode .THROTTLING ) {
84110 throttling [0 ] += 1 ;
85111 }
86112 });
87113
88- // Replaces com.amazonaws.util.AWSRequestMetrics.Field.ClientExecuteTime
89114 timing (m , CoreMetric .API_CALL_DURATION ,
90115 collector ::noteAwsClientExecuteTime );
91116
92- // Replaces com.amazonaws.util.AWSRequestMetrics.Field.HttpRequestTime
93117 timing (m , CoreMetric .SERVICE_CALL_DURATION ,
94118 collector ::noteAwsRequestTime );
95119
96- // Replaces com.amazonaws.util.AWSRequestMetrics.Field.RequestMarshallTime
97120 timing (m , CoreMetric .MARSHALLING_DURATION ,
98121 collector ::noteRequestMarshallTime );
99122
100- // Replaces com.amazonaws.util.AWSRequestMetrics.Field.RequestSigningTime
101123 timing (m , CoreMetric .SIGNING_DURATION ,
102124 collector ::noteRequestSigningTime );
103125
104- // TODO: confirm replacement
105- // Replaces com.amazonaws.util.AWSRequestMetrics.Field.ResponseProcessingTime
106126 timing (m , CoreMetric .UNMARSHALLING_DURATION ,
107127 collector ::noteResponseProcessingTime );
108128 });
0 commit comments