Skip to content

Commit d6b9e0a

Browse files
committed
refactor(telemetry): 将硬编码的key_count替换为TelemetryConstants中的常量
1 parent db6a9aa commit d6b9e0a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/L2Cache.Abstractions/Telemetry/TelemetryConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static class TagNames
5858
public const string KeyPattern = "key_pattern";
5959
public const string ValueType = "value_type";
6060
public const string Source = "source";
61+
public const string KeyCount = "key_count";
6162
}
6263

6364
/// <summary>

src/L2Cache/AbstractCacheService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ public virtual async Task<Dictionary<TKey, TValue>> BatchGetAsync(List<TKey> key
859859
tags:
860860
[
861861
new KeyValuePair<string, object>(TelemetryConstants.TagNames.CacheName, GetCacheName()),
862-
new KeyValuePair<string, object>("key_count", keyList.Count)
862+
new KeyValuePair<string, object>(TelemetryConstants.TagNames.KeyCount, keyList.Count)
863863
]);
864864

865865
var missingKeys = new List<(TKey Key, string FullKey)>();
@@ -946,7 +946,7 @@ public virtual async Task<Dictionary<TKey, TValue>> BatchGetOrLoadAsync(List<TKe
946946
tags:
947947
[
948948
new KeyValuePair<string, object>(TelemetryConstants.TagNames.CacheName, GetCacheName()),
949-
new KeyValuePair<string, object>("key_count", keyList.Count)
949+
new KeyValuePair<string, object>(TelemetryConstants.TagNames.KeyCount, keyList.Count)
950950
]);
951951

952952
// 1. 尝试批量获取缓存
@@ -1072,7 +1072,7 @@ public virtual async Task<long> BatchEvictAsync(List<TKey> keyList)
10721072
tags:
10731073
[
10741074
new KeyValuePair<string, object>(TelemetryConstants.TagNames.CacheName, GetCacheName()),
1075-
new KeyValuePair<string, object>("key_count", keyList.Count)
1075+
new KeyValuePair<string, object>(TelemetryConstants.TagNames.KeyCount, keyList.Count)
10761076
]);
10771077

10781078
// 1. Remove from Local Cache

0 commit comments

Comments
 (0)