Improve XML documentation coverage across src modules and sync generated analysis artifacts.
This commit is contained in:
@@ -11,12 +11,17 @@ public sealed class ServiceLatencyTracker
|
||||
private readonly int _maxSamples;
|
||||
private long _totalRequests;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a latency tracker with a bounded in-memory sample window.
|
||||
/// </summary>
|
||||
/// <param name="maxSamples">Maximum number of latency samples retained for percentile calculations.</param>
|
||||
public ServiceLatencyTracker(int maxSamples = 10000)
|
||||
{
|
||||
_maxSamples = maxSamples;
|
||||
}
|
||||
|
||||
/// <summary>Records a latency sample in milliseconds.</summary>
|
||||
/// <param name="latencyMs">Observed end-to-end service latency in milliseconds.</param>
|
||||
public void RecordLatency(double latencyMs)
|
||||
{
|
||||
lock (_lock)
|
||||
@@ -28,11 +33,15 @@ public sealed class ServiceLatencyTracker
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns the 50th percentile (median) latency in milliseconds.</summary>
|
||||
public double GetP50() => GetPercentile(0.50);
|
||||
/// <summary>Returns the 90th percentile latency in milliseconds.</summary>
|
||||
public double GetP90() => GetPercentile(0.90);
|
||||
/// <summary>Returns the 99th percentile latency in milliseconds.</summary>
|
||||
public double GetP99() => GetPercentile(0.99);
|
||||
|
||||
/// <summary>Returns the value at the given percentile (0.0–1.0) over recorded samples.</summary>
|
||||
/// <param name="percentile">Percentile fraction between 0.0 and 1.0.</param>
|
||||
public double GetPercentile(double percentile)
|
||||
{
|
||||
lock (_lock)
|
||||
@@ -61,16 +70,19 @@ public sealed class ServiceLatencyTracker
|
||||
return sum / samples.Count;
|
||||
}
|
||||
|
||||
/// <summary>Total number of latency observations recorded.</summary>
|
||||
public long TotalRequests
|
||||
{
|
||||
get { lock (_lock) return _totalRequests; }
|
||||
}
|
||||
|
||||
/// <summary>Arithmetic mean latency across currently retained samples.</summary>
|
||||
public double AverageLatencyMs
|
||||
{
|
||||
get { lock (_lock) return ComputeAverage(_samples); }
|
||||
}
|
||||
|
||||
/// <summary>Minimum latency among currently retained samples.</summary>
|
||||
public double MinLatencyMs
|
||||
{
|
||||
get
|
||||
@@ -80,6 +92,7 @@ public sealed class ServiceLatencyTracker
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Maximum latency among currently retained samples.</summary>
|
||||
public double MaxLatencyMs
|
||||
{
|
||||
get
|
||||
@@ -89,6 +102,7 @@ public sealed class ServiceLatencyTracker
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Number of samples currently retained in memory.</summary>
|
||||
public int SampleCount
|
||||
{
|
||||
get { lock (_lock) return _samples.Count; }
|
||||
|
||||
Reference in New Issue
Block a user