public String getClientLatency() {
    if (!enabled) {
      return null;
    }

    Instant trackerStart = Instant.now();
    String latencyDetails = queue.poll(); // non-blocking pop

    if (LOG.isDebugEnabled()) {
      Instant stop = Instant.now();
      long elapsed = Duration.between(trackerStart, stop).toMillis();
      LOG.debug("Dequeued latency info [{} ms]: {}", elapsed, latencyDetails);
    }

    return latencyDetails;
  }
@Test
  public void verifyGettingLatencyRecordsIsCheapWhenDisabled() throws Exception {
    // when latency tracker is disabled, we expect it to take time equivalent to checking a boolean value
    final double maxLatencyWhenDisabledMs = 1000;
    final double minLatencyWhenDisabledMs = 0;
    final long numTasks = 1000;
    long aggregateLatency = 0;
    AbfsPerfTracker abfsPerfTracker = new AbfsPerfTracker(accountName, filesystemName, false);
    List<Callable<Long>> tasks = new ArrayList<>();

    for (int i = 0; i < numTasks; i++) {
      tasks.add(() -> {
        Instant startGet = Instant.now();
        abfsPerfTracker.getClientLatency();
        long latencyGet = Duration.between(startGet, Instant.now()).toMillis();
        LOG.debug("Spent {} ms in retrieving latency record.", latencyGet);
        return latencyGet;
      });
    }

    for (Future<Long> fr: executorService.invokeAll(tasks)) {
      aggregateLatency += fr.get();
    }

    double averageRecordLatency = aggregateLatency / numTasks;
    assertThat(averageRecordLatency).describedAs("Average time for getting latency records should be bounded")
      .isBetween(minLatencyWhenDisabledMs, maxLatencyWhenDisabledMs);
  }