12345678910111213141516171819202122232425 |
- using System.Collections.Concurrent;
- namespace AipGateway.AIP.Service.Metrics
- {
- public class MetircsCollector
- {
- private readonly ConcurrentDictionary<string, long> _metrics = new ConcurrentDictionary<string, long>();
- public void Increment(string metricName)
- {
- if (!_metrics.ContainsKey(metricName))
- {
- _metrics.TryAdd(metricName, 1);
- return;
- }
- _metrics[metricName]++;
- }
- public long GetValue(string metricName)
- {
- return _metrics.GetValueOrDefault(metricName, 0);
- }
- }
- }
|