Skip to content

Commit d376a94

Browse files
roudech1zoewangg
authored andcommitted
Avoid costly metrics collection when metric collector is NoOpMetricCollector
1 parent a2a2daa commit d376a94

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"category": "AWS SDK for Java v2",
3+
"contributor": "@croudet",
4+
"type": "bugfix",
5+
"description": "Avoid costly metrics collection when metric collector is NoOpMetricCollector."
6+
}

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/util/MetricUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static <T> Pair<T, Duration> measureDurationUnsafe(Callable<T> c) throws
6767
}
6868

6969
public static void collectHttpMetrics(MetricCollector metricCollector, SdkHttpFullResponse httpResponse) {
70-
if (metricCollector != null && httpResponse != null) {
70+
if (metricCollector != null && !(metricCollector instanceof NoOpMetricCollector) && httpResponse != null) {
7171
metricCollector.reportMetric(HttpMetric.HTTP_STATUS_CODE, httpResponse.statusCode());
7272
SdkHttpUtils.allMatchingHeadersFromCollection(httpResponse.headers(), X_AMZN_REQUEST_ID_HEADERS)
7373
.forEach(v -> metricCollector.reportMetric(CoreMetric.AWS_REQUEST_ID, v));

0 commit comments

Comments
 (0)