serilog-sinks-periodicbatching
serilog-sinks-periodicbatching copied to clipboard
Expose a way to monitor the queue state
Hello there,
I'm using the periodicbatching through elasticsearch-sink, and i'd like to be able to monitor the state of the bounded queue.
Unless i'm missing something, there's no way to know if my system is producing more logs than it can digest, and i'd find it useful to receive an alert before starting to drop LogEvents.
Something like adding in the PeriodicBatchingSinkOptions
- a callback that would be triggered after a given threshold is reached
- a callback that would be triggered when we're back to below this threshold
- the threshold itself
Of course that would be useful for me only if elasticsearch-sink is ok to use those new settings, i'll ping them after your answer :)
Please let me know, i can do a PR if you're OK with the idea.
Hi! Sounds good to explore, thanks!
@nblumhardt gentle reminder: do you think you'll have time to review my PR soon ?
same problem here. Using Serilog.Sinks.Splunk and spamming my logger
there's a call to _queue.TryEnqueue(logEvent) that doesn't use the boolean return value which can return false.
public bool TryEnqueue(T item)
{
if (_queueLimit == -1)
{
_queue.Enqueue(item);
return true;
}
bool result = true;
try
{
}
finally
{
if (Interlocked.Increment(ref _counter) <= _queueLimit)
{
_queue.Enqueue(item);
}
else
{
Interlocked.Decrement(ref _counter);
result = false;
}
}
return result;
}