29 lines
1.5 KiB
C#
29 lines
1.5 KiB
C#
using System.Diagnostics.Metrics;
|
|
|
|
namespace StellaOps.Scanner.Queue;
|
|
|
|
internal static class QueueMetrics
|
|
{
|
|
private const string TransportTagName = "transport";
|
|
|
|
private static readonly Meter Meter = new("StellaOps.Scanner.Queue");
|
|
private static readonly Counter<long> EnqueuedCounter = Meter.CreateCounter<long>("scanner_queue_enqueued_total");
|
|
private static readonly Counter<long> DeduplicatedCounter = Meter.CreateCounter<long>("scanner_queue_deduplicated_total");
|
|
private static readonly Counter<long> AckCounter = Meter.CreateCounter<long>("scanner_queue_ack_total");
|
|
private static readonly Counter<long> RetryCounter = Meter.CreateCounter<long>("scanner_queue_retry_total");
|
|
private static readonly Counter<long> DeadLetterCounter = Meter.CreateCounter<long>("scanner_queue_deadletter_total");
|
|
|
|
public static void RecordEnqueued(string transport) => EnqueuedCounter.Add(1, BuildTags(transport));
|
|
|
|
public static void RecordDeduplicated(string transport) => DeduplicatedCounter.Add(1, BuildTags(transport));
|
|
|
|
public static void RecordAck(string transport) => AckCounter.Add(1, BuildTags(transport));
|
|
|
|
public static void RecordRetry(string transport) => RetryCounter.Add(1, BuildTags(transport));
|
|
|
|
public static void RecordDeadLetter(string transport) => DeadLetterCounter.Add(1, BuildTags(transport));
|
|
|
|
private static KeyValuePair<string, object?>[] BuildTags(string transport)
|
|
=> new[] { new KeyValuePair<string, object?>(TransportTagName, transport) };
|
|
}
|