private void configureStatisticsRecording(final Caffeine<?, ?> newCacheBuilder,
                                              final CacheConfig cacheConfig) {
        final StatisticsMode statisticsMode = Objects.requireNonNullElse(
                cacheConfig.getStatisticsMode(),
                CacheConfig.DEFAULT_STATISTICS_MODE);

        switch (statisticsMode) {
            case NONE -> {
                // no-op
            }
            case INTERNAL -> newCacheBuilder.recordStats();
            case DROPWIZARD_METRICS -> newCacheBuilder.recordStats(() -> {
                //  https://metrics.dropwizard.io/4.2.0/manual/caffeine.html
                final Metrics metrics = NullSafe.get(metricsProvider, Provider::get);
                Objects.requireNonNull(
                        metrics,
                        "metrics or its provider is null. You must supply a " +
                        "metrics provider to use StatisticsMode "
                        + StatisticsMode.DROPWIZARD_METRICS + " or change the cache config to use "
                        + StatisticsMode.INTERNAL);
                return new MetricsStatsCounter(metrics.getRegistry(), MetricsUtil.buildName(getClass(), name));
            });
        }
    }
Subclasses should implement this method to add to the cacheBuilder as required
and return a cache built from cacheBuilder. The builder already has a
removalNotificationConsumer if applicable and recordStats has been set.
stroom-cache/stroom-cache-impl/src/main/java/stroom/cache/impl/AbstractStroomCache.java