using System; using System.Diagnostics; using System.Diagnostics.Metrics; namespace StellaOps.Provcache; public static partial class ProvcacheTelemetry { /// /// Record operation latency. /// /// The operation type. /// The operation duration. public static void RecordLatency(string operation, TimeSpan duration) { if (string.IsNullOrWhiteSpace(operation)) return; var seconds = duration.TotalSeconds; if (double.IsNaN(seconds) || double.IsInfinity(seconds) || seconds < 0) seconds = 0d; var tags = new TagList { { "operation", operation } }; _latencyHistogram.Record(seconds, tags); } /// /// Record cache entry size. /// /// The size in bytes. public static void RecordEntrySize(long bytes) { if (bytes < 0) return; _entrySizeHistogram.Record(bytes); } }