about summary refs log tree commit diff
path: root/MatrixContentFilter/Services/MatrixContentFilterMetrics.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-03-12 19:52:15 +0100
committerRory& <root@rory.gay>2025-03-12 19:52:15 +0100
commitbdf058ab5c936463a022f62ffbb55bb71c26e856 (patch)
tree69914accad80f10dd8d87e3738e820c58f042537 /MatrixContentFilter/Services/MatrixContentFilterMetrics.cs
parentInitial commit (diff)
downloadMatrixContentFilter-master.tar.xz
More work HEAD master
Diffstat (limited to 'MatrixContentFilter/Services/MatrixContentFilterMetrics.cs')
-rw-r--r--MatrixContentFilter/Services/MatrixContentFilterMetrics.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/MatrixContentFilter/Services/MatrixContentFilterMetrics.cs b/MatrixContentFilter/Services/MatrixContentFilterMetrics.cs
new file mode 100644

index 0000000..ff88cad --- /dev/null +++ b/MatrixContentFilter/Services/MatrixContentFilterMetrics.cs
@@ -0,0 +1,16 @@ +using System.Collections.Frozen; +using System.Diagnostics.Metrics; + +namespace MatrixContentFilter.Services; + +public class MatrixContentFilterMetrics { + private readonly Meter meter = new Meter("MatrixContentFilter"); + private FrozenDictionary<string, Counter<int>> _counters = FrozenDictionary<string, Counter<int>>.Empty; + + public void Increment(string counter, int value = 1) { + if(!_counters.TryGetValue(counter, out var c)) { + c = meter.CreateCounter<int>(counter); + _counters = _counters.Concat([new KeyValuePair<string, Counter<int>>(counter, c)]).ToFrozenDictionary(); + } + } +} \ No newline at end of file