Class MetricUtils
- java.lang.Object
-
- software.amazon.awssdk.core.internal.util.MetricUtils
-
public final class MetricUtils extends Object
Utility methods for working with metrics.
-
-
Method Summary
-
-
-
Method Detail
-
measureDuration
public static <T> Pair<T,Duration> measureDuration(Supplier<T> c)
Measure the duration of the given callable.- Parameters:
c
- The callable to measure.- Returns:
- A
Pair
containing the result ofc
and the duration.
-
reportDuration
public static <T> CompletableFuture<T> reportDuration(Supplier<CompletableFuture<T>> c, MetricCollector metricCollector, SdkMetric<Duration> metric)
Report a duration metric of the givenCompletableFuture
supplier.- Parameters:
c
- The callable to measure.metricCollector
- The MetricCollector where the metric is to be reported.metric
- The metric to be reported.- Returns:
- A
Pair
containing the result ofc
and the duration.
-
measureDurationUnsafe
public static <T> Pair<T,Duration> measureDurationUnsafe(Callable<T> c) throws Exception
Measure the duration of the given callable.- Parameters:
c
- The callable to measure.- Returns:
- A
Pair
containing the result ofc
and the duration. - Throws:
Exception
-
measureDurationUnsafe
public static <T> Pair<T,Duration> measureDurationUnsafe(Callable<T> c, long startTime) throws Exception
Measure the duration of the given callable, using the provided time as the basis.- Throws:
Exception
-
collectServiceEndpointMetrics
public static void collectServiceEndpointMetrics(MetricCollector metricCollector, SdkHttpFullRequest httpRequest)
Collect the SERVICE_ENDPOINT metric for this request.
-
collectHttpMetrics
public static void collectHttpMetrics(MetricCollector metricCollector, SdkHttpFullResponse httpResponse)
-
createAttemptMetricsCollector
public static MetricCollector createAttemptMetricsCollector(RequestExecutionContext context)
-
createHttpMetricsCollector
public static MetricCollector createHttpMetricsCollector(RequestExecutionContext context)
-
apiCallAttemptStartNanoTime
public static OptionalLong apiCallAttemptStartNanoTime(RequestExecutionContext context)
-
resetApiCallAttemptStartNanoTime
public static long resetApiCallAttemptStartNanoTime(RequestExecutionContext context)
-
apiCallAttemptResponseBytesRead
public static OptionalLong apiCallAttemptResponseBytesRead(RequestExecutionContext context)
-
responseHeadersReadEndNanoTime
public static OptionalLong responseHeadersReadEndNanoTime(RequestExecutionContext context)
-
bytesPerSec
public static double bytesPerSec(long totalBytes, long nanoStart, long nanoEnd)
-
-