70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
using System;
|
|
using Svrnty.CQRS.Events.Abstractions.Streaming;
|
|
using Svrnty.CQRS.Events.Abstractions;
|
|
|
|
namespace Svrnty.CQRS.Events.Metrics;
|
|
|
|
/// <summary>
|
|
/// No-op implementation of <see cref="IEventStreamMetrics"/> for when metrics are disabled.
|
|
/// All methods are empty and have no performance overhead.
|
|
/// </summary>
|
|
public sealed class NoOpEventStreamMetrics : IEventStreamMetrics
|
|
{
|
|
/// <summary>
|
|
/// Singleton instance to avoid allocations.
|
|
/// </summary>
|
|
public static readonly NoOpEventStreamMetrics Instance = new();
|
|
|
|
private NoOpEventStreamMetrics()
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void RecordEventPublished(string streamName, string eventType)
|
|
{
|
|
// No-op
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void RecordEventConsumed(string streamName, string subscriptionId, string eventType)
|
|
{
|
|
// No-op
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void RecordProcessingLatency(string streamName, string subscriptionId, TimeSpan latency)
|
|
{
|
|
// No-op
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void RecordConsumerLag(string streamName, string subscriptionId, long lag)
|
|
{
|
|
// No-op
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void RecordError(string streamName, string? subscriptionId, string errorType)
|
|
{
|
|
// No-op
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void RecordRetry(string streamName, string subscriptionId, int attemptNumber)
|
|
{
|
|
// No-op
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void RecordStreamLength(string streamName, long length)
|
|
{
|
|
// No-op
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void RecordActiveConsumers(string streamName, string subscriptionId, int consumerCount)
|
|
{
|
|
// No-op
|
|
}
|
|
}
|