Class DatabaseMetricsTracker
- Namespace
- FishMMO.Database.Npgsql.Monitoring.Metrics
- Assembly
- FishMMO-DB.dll
Tracks database operation metrics in a thread-safe manner. Records query execution statistics including success/failure rates and response times. Follows Single Responsibility Principle: solely responsible for metrics collection and aggregation. Unity-compatible implementation with no external dependencies.
public sealed class DatabaseMetricsTracker
- Inheritance
-
DatabaseMetricsTracker
- Inherited Members
Constructors
DatabaseMetricsTracker()
Initializes a new instance of the DatabaseMetricsTracker class.
public DatabaseMetricsTracker()
Methods
GetSummary()
Gets a snapshot of current metrics. Returns a new MetricsSummary instance with current values. Thread-safe operation.
public MetricsSummary GetSummary()
Returns
- MetricsSummary
A MetricsSummary containing current metric values.
RecordFailure(TimeSpan, string)
Records a failed database operation. Thread-safe operation using atomic interlocked operations and locking for dictionary access.
public void RecordFailure(TimeSpan responseTime, string errorType)
Parameters
responseTimeTimeSpanTime taken before the operation failed.
errorTypestringType or category of error that occurred (e.g., "Timeout", "ConnectionFailed").
RecordSuccess(TimeSpan)
Records a successful database operation. Thread-safe operation using atomic interlocked operations.
public void RecordSuccess(TimeSpan responseTime)
Parameters
responseTimeTimeSpanTime taken for the operation to complete.
Reset()
Resets all metrics counters to their initial state. Thread-safe operation.
public void Reset()