in metrics-core/src/main/java/software/amazon/swage/metrics/record/cloudwatch/CloudWatchRecorder.java [354:378]
public void shutdown() {
boolean wasRunning = running.getAndSet(false);
if (!wasRunning){
// shutdown already called
return;
}
// Schedule one last flush to make sure everything gets sent; this will
// either execute immediately or queue up behind an in-flight flush
// (and be cancelled). Worst case it gets executed immediately after
// a previous one completes, which is fine.
publishExecutor.execute(this::sendAggregatedData);
// And shut down the publish thread, waiting to make sure our last
// flush executes.
publishExecutor.shutdown();
try {
publishExecutor.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.SECONDS);
} catch (InterruptedException e) {
// (Re-)Cancel if current thread also interrupted
publishExecutor.shutdownNow();
// Preserve interrupt status
Thread.currentThread().interrupt();
}
}