Table of Contents

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

operationName string

The name of the database operation.

maxRecentSamples int

Maximum number of recent samples to keep for percentile calculation.

Properties

AverageMs

Gets the average execution time in milliseconds.

public double AverageMs { get; }

Property Value

double

FailedExecutions

Gets the number of failed executions.

public long FailedExecutions { get; }

Property Value

long

MaxMs

Gets the maximum execution time in milliseconds.

public double MaxMs { get; }

Property Value

double

MinMs

Gets the minimum execution time in milliseconds.

public double MinMs { get; }

Property Value

double

OperationName

Gets the name of the database operation being tracked.

public string OperationName { get; }

Property Value

string

P95Ms

Gets the 95th percentile execution time in milliseconds. Returns 0 if insufficient samples.

public double P95Ms { get; }

Property Value

double

P99Ms

Gets the 99th percentile execution time in milliseconds. Returns 0 if insufficient samples.

public double P99Ms { get; }

Property Value

double

SlowQueryCount

Gets the number of executions that exceeded the slow query threshold.

public long SlowQueryCount { get; }

Property Value

long

SuccessRate

Gets the success rate as a percentage (0-100).

public double SuccessRate { get; }

Property Value

double

SuccessfulExecutions

Gets the number of successful executions.

public long SuccessfulExecutions { get; }

Property Value

long

TotalExecutions

Gets the total number of executions.

public long TotalExecutions { get; }

Property Value

long

Methods

RecordExecution(TimeSpan, bool, double)

Records a query execution. Thread-safe operation.

public void RecordExecution(TimeSpan duration, bool success, double slowQueryThresholdMs = 1000)

Parameters

duration TimeSpan

The execution duration.

success bool

Whether the execution succeeded.

slowQueryThresholdMs double

The 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()

Returns

string