public final class MetricUtils extends Object
Implementation notes: this class should've been outside internal package, but we can't fix it due to backwards compatibility reasons.
public static <T> Pair<T,Duration> measureDuration(Supplier<T> c)
c - The callable to measure.Pair containing the result of c and the duration.public static <T> CompletableFuture<T> reportDuration(Supplier<CompletableFuture<T>> c, MetricCollector metricCollector, SdkMetric<Duration> metric)
CompletableFuture supplier.c - The callable to measure.metricCollector - The MetricCollector where the metric is to be reported.metric - The metric to be reported.Pair containing the result of c and the duration.public static <T> Pair<T,Duration> measureDurationUnsafe(Callable<T> c) throws Exception
c - The callable to measure.Pair containing the result of c and the duration.Exceptionpublic static <T> Pair<T,Duration> measureDurationUnsafe(Callable<T> c, long startTime) throws Exception
Exceptionpublic static void collectServiceEndpointMetrics(MetricCollector metricCollector, SdkHttpFullRequest httpRequest)
public static void collectHttpMetrics(MetricCollector metricCollector, SdkHttpFullResponse httpResponse)
public static MetricCollector createAttemptMetricsCollector(RequestExecutionContext context)
public static MetricCollector createHttpMetricsCollector(RequestExecutionContext context)
public static OptionalLong apiCallAttemptStartNanoTime(RequestExecutionContext context)
public static long resetApiCallAttemptStartNanoTime(RequestExecutionContext context)
public static OptionalLong apiCallAttemptResponseBytesRead(RequestExecutionContext context)
public static OptionalLong responseHeadersReadEndNanoTime(RequestExecutionContext context)
public static double bytesPerSec(long totalBytes,
long nanoStart,
long nanoEnd)
Copyright © 2026. All rights reserved.