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
|