diff --git a/CHANGES.md b/CHANGES.md index 2c41f4b..db5e8ed 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,6 @@ +## 3.5.0 +- [#134](https://github.com/serilog/serilog-sinks-splunk/pull/134) + ## 3.4.0 - [#126](https://github.com/serilog/serilog-sinks-splunk/pull/126) - [#122](https://github.com/serilog/serilog-sinks-splunk/pull/122) diff --git a/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj b/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj index ee6c6c2..42a5248 100644 --- a/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj +++ b/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj @@ -2,7 +2,7 @@ The Splunk Sink for Serilog - 3.4.0 + 3.5.0 Matthew Erbs, Serilog Contributors net45;netstandard1.1;netstandard2.0 true diff --git a/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs b/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs index cdfe05f..5cdfc41 100644 --- a/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs +++ b/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs @@ -31,6 +31,8 @@ namespace Serilog.Sinks.Splunk /// public class EventCollectorSink : PeriodicBatchingSink { + private const int NoQueueLimit = -1; + private readonly string _splunkHost; private readonly string _uriPath; private readonly ITextFormatter _jsonFormatter; @@ -56,11 +58,13 @@ public class EventCollectorSink : PeriodicBatchingSink /// The format provider used when rendering the message /// Whether to render the message template /// The interval in seconds that batching should occur + /// Maximum number of events in the queue public EventCollectorSink( string splunkHost, string eventCollectorToken, int batchIntervalInSeconds = 5, int batchSizeLimit = 100, + int? queueLimit = null, IFormatProvider formatProvider = null, bool renderTemplate = true) : this( @@ -69,6 +73,7 @@ public EventCollectorSink( null, null, null, null, null, batchIntervalInSeconds, batchSizeLimit, + queueLimit, formatProvider, renderTemplate) { @@ -84,6 +89,7 @@ public EventCollectorSink( /// The format provider used when rendering the message /// Whether to render the message template /// The interval in seconds that batching should occur + /// Maximum number of events in the queue /// The Splunk index to log to /// The source of the event /// The source type of the event @@ -99,6 +105,7 @@ public EventCollectorSink( string index, int batchIntervalInSeconds, int batchSizeLimit, + int? queueLimit, IFormatProvider formatProvider = null, bool renderTemplate = true, HttpMessageHandler messageHandler = null) @@ -108,6 +115,7 @@ public EventCollectorSink( uriPath, batchIntervalInSeconds, batchSizeLimit, + queueLimit, new SplunkJsonFormatter(renderTemplate, formatProvider, source, sourceType, host, index), messageHandler) { @@ -120,6 +128,7 @@ public EventCollectorSink( /// The token to use when authenticating with the event collector /// Change the default endpoint of the Event Collector e.g. services/collector/event /// The size of the batch when sending to the event collector + /// Maximum number of events in the queue /// The format provider used when rendering the message /// Whether to render the message template /// The interval in seconds that batching should occur @@ -140,6 +149,7 @@ public EventCollectorSink( CustomFields fields, int batchIntervalInSeconds, int batchSizeLimit, + int? queueLimit, IFormatProvider formatProvider = null, bool renderTemplate = true, HttpMessageHandler messageHandler = null) @@ -150,6 +160,7 @@ public EventCollectorSink( uriPath, batchIntervalInSeconds, batchSizeLimit, + queueLimit, new SplunkJsonFormatter(renderTemplate, formatProvider, source, sourceType, host, index, fields), messageHandler) { @@ -163,6 +174,7 @@ public EventCollectorSink( /// Change the default endpoint of the Event Collector e.g. services/collector/event /// The size of the batch when sending to the event collector /// The interval in seconds that batching should occur + /// Maximum number of events in the queue /// The text formatter used to render log events into a JSON format for consumption by Splunk /// The handler used to send HTTP requests public EventCollectorSink( @@ -171,9 +183,10 @@ public EventCollectorSink( string uriPath, int batchIntervalInSeconds, int batchSizeLimit, + int? queueLimit, ITextFormatter jsonFormatter, HttpMessageHandler messageHandler = null) - : base(batchSizeLimit, TimeSpan.FromSeconds(batchIntervalInSeconds)) + : base(batchSizeLimit, TimeSpan.FromSeconds(batchIntervalInSeconds), queueLimit ?? NoQueueLimit) { _uriPath = uriPath; _splunkHost = splunkHost; diff --git a/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs b/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs index 2bc7ae4..1e4d3fd 100644 --- a/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs +++ b/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs @@ -49,6 +49,7 @@ public static class SplunkLoggingConfigurationExtensions /// If true, the message template will be rendered /// The interval in seconds that the queue should be instpected for batching /// The size of the batch + /// Maximum number of events in the queue /// The handler used to send HTTP requests /// A switch allowing the pass-through minimum level to be changed at runtime. /// @@ -66,6 +67,7 @@ public static LoggerConfiguration EventCollector( bool renderTemplate = true, int batchIntervalInSeconds = 2, int batchSizeLimit = 100, + int? queueLimit = null, HttpMessageHandler messageHandler = null, LoggingLevelSwitch levelSwitch = null) { @@ -81,6 +83,7 @@ public static LoggerConfiguration EventCollector( index, batchIntervalInSeconds, batchSizeLimit, + queueLimit, formatProvider, renderTemplate, messageHandler); @@ -97,9 +100,10 @@ public static LoggerConfiguration EventCollector( /// The text formatter used to render log events into a JSON format for consumption by Splunk /// Change the default endpoint of the Event Collector e.g. services/collector/event /// The minimum log event level required in order to write an event to the sink. - + /// The interval in seconds that the queue should be instpected for batching /// The size of the batch + /// Maximum number of events in the queue /// The handler used to send HTTP requests /// A switch allowing the pass-through minimum level to be changed at runtime. /// @@ -112,6 +116,7 @@ public static LoggerConfiguration EventCollector( LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, int batchIntervalInSeconds = 2, int batchSizeLimit = 100, + int? queueLimit = null, HttpMessageHandler messageHandler = null, LoggingLevelSwitch levelSwitch = null) { @@ -124,6 +129,7 @@ public static LoggerConfiguration EventCollector( uriPath, batchIntervalInSeconds, batchSizeLimit, + queueLimit, jsonFormatter, messageHandler); @@ -147,6 +153,7 @@ public static LoggerConfiguration EventCollector( /// If ture, the message template will be rendered /// The interval in seconds that the queue should be instpected for batching /// The size of the batch + /// Maximum number of events in the queue /// The handler used to send HTTP requests /// A switch allowing the pass-through minimum level to be changed at runtime. /// Customfields that will be indexed in splunk with this event @@ -166,6 +173,7 @@ public static LoggerConfiguration EventCollector( bool renderTemplate = true, int batchIntervalInSeconds = 2, int batchSizeLimit = 100, + int? queueLimit = null, HttpMessageHandler messageHandler = null, LoggingLevelSwitch levelSwitch = null) { @@ -182,6 +190,7 @@ public static LoggerConfiguration EventCollector( fields, batchIntervalInSeconds, batchSizeLimit, + queueLimit, formatProvider, renderTemplate, messageHandler