Class QueryMetrics
- Namespace
- FishMMO.Database.Npgsql.Monitoring.Diagnostics
- Assembly
- FishMMO-DB.dll
Tracks performance metrics for a specific database operation. Thread-safe implementation using lock-free operations where possible.
public sealed class QueryMetrics
- Inheritance
-
QueryMetrics
- Inherited Members
Constructors
QueryMetrics(string, int)
Initializes a new instance of QueryMetrics.
public QueryMetrics(string operationName, int maxRecentSamples = 1000)
Parameters
operationNamestringThe name of the database operation.
maxRecentSamplesintMaximum number of recent samples to keep for percentile calculation.
Properties
AverageMs
Gets the average execution time in milliseconds.
public double AverageMs { get; }
Property Value
FailedExecutions
Gets the number of failed executions.
public long FailedExecutions { get; }
Property Value
MaxMs
Gets the maximum execution time in milliseconds.
public double MaxMs { get; }
Property Value
MinMs
Gets the minimum execution time in milliseconds.
public double MinMs { get; }
Property Value
OperationName
Gets the name of the database operation being tracked.
public string OperationName { get; }
Property Value
P95Ms
Gets the 95th percentile execution time in milliseconds. Returns 0 if insufficient samples.
public double P95Ms { get; }
Property Value
P99Ms
Gets the 99th percentile execution time in milliseconds. Returns 0 if insufficient samples.
public double P99Ms { get; }
Property Value
SlowQueryCount
Gets the number of executions that exceeded the slow query threshold.
public long SlowQueryCount { get; }
Property Value
SuccessRate
Gets the success rate as a percentage (0-100).
public double SuccessRate { get; }
Property Value
SuccessfulExecutions
Gets the number of successful executions.
public long SuccessfulExecutions { get; }
Property Value
TotalExecutions
Gets the total number of executions.
public long TotalExecutions { get; }
Property Value
Methods
RecordExecution(TimeSpan, bool, double)
Records a query execution. Thread-safe operation.
public void RecordExecution(TimeSpan duration, bool success, double slowQueryThresholdMs = 1000)
Parameters
durationTimeSpanThe execution duration.
successboolWhether the execution succeeded.
slowQueryThresholdMsdoubleThe threshold for considering a query slow.
Reset()
Resets all metrics to initial state.
public void Reset()
ToString()
Returns a formatted string representation of the metrics.
public override string ToString()