Reformat / cleanup
This commit is contained in:
@@ -1,111 +1,109 @@
|
||||
using System.Threading;
|
||||
|
||||
namespace ZB.MOM.WW.CBDD.Core.Compression;
|
||||
|
||||
/// <summary>
|
||||
/// Thread-safe counters for compression/decompression lifecycle events.
|
||||
/// Thread-safe counters for compression/decompression lifecycle events.
|
||||
/// </summary>
|
||||
public sealed class CompressionTelemetry
|
||||
{
|
||||
private long _checksumFailureCount;
|
||||
private long _compressedDocumentCount;
|
||||
private long _compressionAttempts;
|
||||
private long _compressionSuccesses;
|
||||
private long _compressionCpuTicks;
|
||||
private long _compressionFailures;
|
||||
private long _compressionSkippedTooSmall;
|
||||
private long _compressionSkippedInsufficientSavings;
|
||||
private long _decompressionAttempts;
|
||||
private long _decompressionSuccesses;
|
||||
private long _decompressionFailures;
|
||||
private long _compressionInputBytes;
|
||||
private long _compressionOutputBytes;
|
||||
private long _decompressionOutputBytes;
|
||||
private long _compressedDocumentCount;
|
||||
private long _compressionCpuTicks;
|
||||
private long _compressionSkippedInsufficientSavings;
|
||||
private long _compressionSkippedTooSmall;
|
||||
private long _compressionSuccesses;
|
||||
private long _decompressionAttempts;
|
||||
private long _decompressionCpuTicks;
|
||||
private long _checksumFailureCount;
|
||||
private long _decompressionFailures;
|
||||
private long _decompressionOutputBytes;
|
||||
private long _decompressionSuccesses;
|
||||
private long _safetyLimitRejectionCount;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of attempted compression operations.
|
||||
/// Gets the number of attempted compression operations.
|
||||
/// </summary>
|
||||
public long CompressionAttempts => Interlocked.Read(ref _compressionAttempts);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of successful compression operations.
|
||||
/// Gets the number of successful compression operations.
|
||||
/// </summary>
|
||||
public long CompressionSuccesses => Interlocked.Read(ref _compressionSuccesses);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of failed compression operations.
|
||||
/// Gets the number of failed compression operations.
|
||||
/// </summary>
|
||||
public long CompressionFailures => Interlocked.Read(ref _compressionFailures);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of compression attempts skipped because payloads were too small.
|
||||
/// Gets the number of compression attempts skipped because payloads were too small.
|
||||
/// </summary>
|
||||
public long CompressionSkippedTooSmall => Interlocked.Read(ref _compressionSkippedTooSmall);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of compression attempts skipped due to insufficient savings.
|
||||
/// Gets the number of compression attempts skipped due to insufficient savings.
|
||||
/// </summary>
|
||||
public long CompressionSkippedInsufficientSavings => Interlocked.Read(ref _compressionSkippedInsufficientSavings);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of attempted decompression operations.
|
||||
/// Gets the number of attempted decompression operations.
|
||||
/// </summary>
|
||||
public long DecompressionAttempts => Interlocked.Read(ref _decompressionAttempts);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of successful decompression operations.
|
||||
/// Gets the number of successful decompression operations.
|
||||
/// </summary>
|
||||
public long DecompressionSuccesses => Interlocked.Read(ref _decompressionSuccesses);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of failed decompression operations.
|
||||
/// Gets the number of failed decompression operations.
|
||||
/// </summary>
|
||||
public long DecompressionFailures => Interlocked.Read(ref _decompressionFailures);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total input bytes observed by compression attempts.
|
||||
/// Gets the total input bytes observed by compression attempts.
|
||||
/// </summary>
|
||||
public long CompressionInputBytes => Interlocked.Read(ref _compressionInputBytes);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total output bytes produced by successful compression attempts.
|
||||
/// Gets the total output bytes produced by successful compression attempts.
|
||||
/// </summary>
|
||||
public long CompressionOutputBytes => Interlocked.Read(ref _compressionOutputBytes);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total output bytes produced by successful decompression attempts.
|
||||
/// Gets the total output bytes produced by successful decompression attempts.
|
||||
/// </summary>
|
||||
public long DecompressionOutputBytes => Interlocked.Read(ref _decompressionOutputBytes);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of documents stored in compressed form.
|
||||
/// Gets the number of documents stored in compressed form.
|
||||
/// </summary>
|
||||
public long CompressedDocumentCount => Interlocked.Read(ref _compressedDocumentCount);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total CPU ticks spent on compression.
|
||||
/// Gets the total CPU ticks spent on compression.
|
||||
/// </summary>
|
||||
public long CompressionCpuTicks => Interlocked.Read(ref _compressionCpuTicks);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total CPU ticks spent on decompression.
|
||||
/// Gets the total CPU ticks spent on decompression.
|
||||
/// </summary>
|
||||
public long DecompressionCpuTicks => Interlocked.Read(ref _decompressionCpuTicks);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of checksum validation failures.
|
||||
/// Gets the number of checksum validation failures.
|
||||
/// </summary>
|
||||
public long ChecksumFailureCount => Interlocked.Read(ref _checksumFailureCount);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of decompression safety-limit rejections.
|
||||
/// Gets the number of decompression safety-limit rejections.
|
||||
/// </summary>
|
||||
public long SafetyLimitRejectionCount => Interlocked.Read(ref _safetyLimitRejectionCount);
|
||||
|
||||
/// <summary>
|
||||
/// Records a compression attempt and its input byte size.
|
||||
/// Records a compression attempt and its input byte size.
|
||||
/// </summary>
|
||||
/// <param name="inputBytes">The number of input bytes provided to compression.</param>
|
||||
public void RecordCompressionAttempt(int inputBytes)
|
||||
@@ -115,7 +113,7 @@ public sealed class CompressionTelemetry
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records a successful compression operation.
|
||||
/// Records a successful compression operation.
|
||||
/// </summary>
|
||||
/// <param name="outputBytes">The number of compressed bytes produced.</param>
|
||||
public void RecordCompressionSuccess(int outputBytes)
|
||||
@@ -126,49 +124,73 @@ public sealed class CompressionTelemetry
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records a failed compression operation.
|
||||
/// Records a failed compression operation.
|
||||
/// </summary>
|
||||
public void RecordCompressionFailure() => Interlocked.Increment(ref _compressionFailures);
|
||||
public void RecordCompressionFailure()
|
||||
{
|
||||
Interlocked.Increment(ref _compressionFailures);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records that compression was skipped because the payload was too small.
|
||||
/// Records that compression was skipped because the payload was too small.
|
||||
/// </summary>
|
||||
public void RecordCompressionSkippedTooSmall() => Interlocked.Increment(ref _compressionSkippedTooSmall);
|
||||
public void RecordCompressionSkippedTooSmall()
|
||||
{
|
||||
Interlocked.Increment(ref _compressionSkippedTooSmall);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records that compression was skipped due to insufficient expected savings.
|
||||
/// Records that compression was skipped due to insufficient expected savings.
|
||||
/// </summary>
|
||||
public void RecordCompressionSkippedInsufficientSavings() => Interlocked.Increment(ref _compressionSkippedInsufficientSavings);
|
||||
public void RecordCompressionSkippedInsufficientSavings()
|
||||
{
|
||||
Interlocked.Increment(ref _compressionSkippedInsufficientSavings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records a decompression attempt.
|
||||
/// Records a decompression attempt.
|
||||
/// </summary>
|
||||
public void RecordDecompressionAttempt() => Interlocked.Increment(ref _decompressionAttempts);
|
||||
public void RecordDecompressionAttempt()
|
||||
{
|
||||
Interlocked.Increment(ref _decompressionAttempts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds CPU ticks spent performing compression.
|
||||
/// Adds CPU ticks spent performing compression.
|
||||
/// </summary>
|
||||
/// <param name="ticks">The CPU ticks to add.</param>
|
||||
public void RecordCompressionCpuTicks(long ticks) => Interlocked.Add(ref _compressionCpuTicks, ticks);
|
||||
public void RecordCompressionCpuTicks(long ticks)
|
||||
{
|
||||
Interlocked.Add(ref _compressionCpuTicks, ticks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds CPU ticks spent performing decompression.
|
||||
/// Adds CPU ticks spent performing decompression.
|
||||
/// </summary>
|
||||
/// <param name="ticks">The CPU ticks to add.</param>
|
||||
public void RecordDecompressionCpuTicks(long ticks) => Interlocked.Add(ref _decompressionCpuTicks, ticks);
|
||||
public void RecordDecompressionCpuTicks(long ticks)
|
||||
{
|
||||
Interlocked.Add(ref _decompressionCpuTicks, ticks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records a checksum validation failure.
|
||||
/// Records a checksum validation failure.
|
||||
/// </summary>
|
||||
public void RecordChecksumFailure() => Interlocked.Increment(ref _checksumFailureCount);
|
||||
public void RecordChecksumFailure()
|
||||
{
|
||||
Interlocked.Increment(ref _checksumFailureCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records a decompression rejection due to safety limits.
|
||||
/// Records a decompression rejection due to safety limits.
|
||||
/// </summary>
|
||||
public void RecordSafetyLimitRejection() => Interlocked.Increment(ref _safetyLimitRejectionCount);
|
||||
public void RecordSafetyLimitRejection()
|
||||
{
|
||||
Interlocked.Increment(ref _safetyLimitRejectionCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records a successful decompression operation.
|
||||
/// Records a successful decompression operation.
|
||||
/// </summary>
|
||||
/// <param name="outputBytes">The number of decompressed bytes produced.</param>
|
||||
public void RecordDecompressionSuccess(int outputBytes)
|
||||
@@ -178,12 +200,15 @@ public sealed class CompressionTelemetry
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records a failed decompression operation.
|
||||
/// Records a failed decompression operation.
|
||||
/// </summary>
|
||||
public void RecordDecompressionFailure() => Interlocked.Increment(ref _decompressionFailures);
|
||||
public void RecordDecompressionFailure()
|
||||
{
|
||||
Interlocked.Increment(ref _decompressionFailures);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a point-in-time snapshot of compression telemetry.
|
||||
/// Returns a point-in-time snapshot of compression telemetry.
|
||||
/// </summary>
|
||||
/// <returns>The aggregated compression statistics.</returns>
|
||||
public CompressionStats GetSnapshot()
|
||||
@@ -200,4 +225,4 @@ public sealed class CompressionTelemetry
|
||||
SafetyLimitRejectionCount = SafetyLimitRejectionCount
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user