Class MetricUtils
java.lang.Object
software.amazon.awssdk.core.internal.util.MetricUtils
Utility methods for working with metrics.
-
Method Summary
Modifier and TypeMethodDescriptionstatic OptionalLong
static OptionalLong
static double
bytesPerSec
(long totalBytes, long nanoStart, long nanoEnd) static void
collectHttpMetrics
(MetricCollector metricCollector, SdkHttpFullResponse httpResponse) static void
collectServiceEndpointMetrics
(MetricCollector metricCollector, SdkHttpFullRequest httpRequest) Collect the SERVICE_ENDPOINT metric for this request.static MetricCollector
static MetricCollector
measureDuration
(Supplier<T> c) Measure the duration of the given callable.Measure the duration of the given callable.measureDurationUnsafe
(Callable<T> c, long startTime) Measure the duration of the given callable, using the provided time as the basis.static <T> CompletableFuture
<T> reportDuration
(Supplier<CompletableFuture<T>> c, MetricCollector metricCollector, SdkMetric<Duration> metric) Report a duration metric of the givenCompletableFuture
supplier.static long
static OptionalLong
-
Method Details
-
measureDuration
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
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
-
createHttpMetricsCollector
-
apiCallAttemptStartNanoTime
-
resetApiCallAttemptStartNanoTime
-
apiCallAttemptResponseBytesRead
-
responseHeadersReadEndNanoTime
-
bytesPerSec
public static double bytesPerSec(long totalBytes, long nanoStart, long nanoEnd)
-