public void CollectMetrics() { foreach (var stats in _cacheStats.Keys) { if (stats.CountHits == 0 && stats.CountMisses == 0 && stats.CountEjections == 0 && stats.Size == 0) { continue; } var metricNamePrefix = _cacheStats[stats]; TrySend(_metricBuilder.TryBuildCacheCountMetric(metricNamePrefix + "Hits", stats.CountHits)); TrySend(_metricBuilder.TryBuildCacheCountMetric(metricNamePrefix + "Misses", stats.CountMisses)); TrySend(_metricBuilder.TryBuildCacheCountMetric(metricNamePrefix + "Ejections", stats.CountEjections)); TrySend(_metricBuilder.TryBuildCacheSizeMetric(metricNamePrefix + "Size", stats.Size)); TrySend(_metricBuilder.TryBuildCacheSizeMetric(metricNamePrefix + "Capacity", stats.Capacity)); stats.ResetStats(); } }