Class MetricUtils


  • public final class MetricUtils
    extends Object
    Utility methods for working with metrics.
    • 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 of c 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 of c 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.
      • resetApiCallAttemptStartNanoTime

        public static long resetApiCallAttemptStartNanoTime​(RequestExecutionContext context)
      • bytesPerSec

        public static double bytesPerSec​(long totalBytes,
                                         long nanoStart,
                                         long nanoEnd)