From 0544cc39cb06a45be3762582835683e3287d1550 Mon Sep 17 00:00:00 2001 From: Joseph Shook Date: Wed, 7 Feb 2024 09:36:11 -0800 Subject: [PATCH 1/2] Add the evict reason as a metric tag so we can categorize the evict reason. --- .../Events/FusionCacheMemoryEventsHub.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZiggyCreatures.FusionCache/Events/FusionCacheMemoryEventsHub.cs b/src/ZiggyCreatures.FusionCache/Events/FusionCacheMemoryEventsHub.cs index 79b615a7..92eea0ed 100644 --- a/src/ZiggyCreatures.FusionCache/Events/FusionCacheMemoryEventsHub.cs +++ b/src/ZiggyCreatures.FusionCache/Events/FusionCacheMemoryEventsHub.cs @@ -45,7 +45,7 @@ public bool HasEvictionSubscribers() internal void OnEviction(string operationId, string key, EvictionReason reason, object? value) { - Metrics.CounterMemoryEvict.Maybe()?.AddWithCommonTags(1, _cache.CacheName, _cache.InstanceId); + Metrics.CounterMemoryEvict.Maybe()?.AddWithCommonTags(1, _cache.CacheName, _cache.InstanceId, new KeyValuePair("fusioncache.evict.reason", reason.ToString())); Eviction?.SafeExecute(operationId, key, _cache, () => new FusionCacheEntryEvictionEventArgs(key, reason, value), nameof(Eviction), _logger, _errorsLogLevel, _syncExecution); } From 9dd0f00f419dde6cd5a96da1db4b1de906e0e855 Mon Sep 17 00:00:00 2001 From: Jody Donetti Date: Thu, 8 Feb 2024 00:01:57 +0100 Subject: [PATCH 2/2] I suggest a slightly different name, more aligned with the existing "fusioncache.memory.evict" used for the counter CounterMemoryEvict --- .../Events/FusionCacheMemoryEventsHub.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZiggyCreatures.FusionCache/Events/FusionCacheMemoryEventsHub.cs b/src/ZiggyCreatures.FusionCache/Events/FusionCacheMemoryEventsHub.cs index 92eea0ed..70a251e6 100644 --- a/src/ZiggyCreatures.FusionCache/Events/FusionCacheMemoryEventsHub.cs +++ b/src/ZiggyCreatures.FusionCache/Events/FusionCacheMemoryEventsHub.cs @@ -45,7 +45,7 @@ public bool HasEvictionSubscribers() internal void OnEviction(string operationId, string key, EvictionReason reason, object? value) { - Metrics.CounterMemoryEvict.Maybe()?.AddWithCommonTags(1, _cache.CacheName, _cache.InstanceId, new KeyValuePair("fusioncache.evict.reason", reason.ToString())); + Metrics.CounterMemoryEvict.Maybe()?.AddWithCommonTags(1, _cache.CacheName, _cache.InstanceId, new KeyValuePair("fusioncache.memory.evict_reason", reason.ToString())); Eviction?.SafeExecute(operationId, key, _cache, () => new FusionCacheEntryEvictionEventArgs(key, reason, value), nameof(Eviction), _logger, _errorsLogLevel, _syncExecution); }