@@ -31,6 +31,8 @@ namespace Serilog.Sinks.Splunk
3131 /// </summary>
3232 public class EventCollectorSink : PeriodicBatchingSink
3333 {
34+ private const int NoQueueLimit = - 1 ;
35+
3436 private readonly string _splunkHost ;
3537 private readonly string _uriPath ;
3638 private readonly ITextFormatter _jsonFormatter ;
@@ -56,11 +58,13 @@ public class EventCollectorSink : PeriodicBatchingSink
5658 /// <param name="formatProvider">The format provider used when rendering the message</param>
5759 /// <param name="renderTemplate">Whether to render the message template</param>
5860 /// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
61+ /// <param name="queueLimit">Maximum number of events in the queue</param>
5962 public EventCollectorSink (
6063 string splunkHost ,
6164 string eventCollectorToken ,
6265 int batchIntervalInSeconds = 5 ,
6366 int batchSizeLimit = 100 ,
67+ int ? queueLimit = null ,
6468 IFormatProvider formatProvider = null ,
6569 bool renderTemplate = true )
6670 : this (
@@ -69,6 +73,7 @@ public EventCollectorSink(
6973 null , null , null , null , null ,
7074 batchIntervalInSeconds ,
7175 batchSizeLimit ,
76+ queueLimit ,
7277 formatProvider ,
7378 renderTemplate )
7479 {
@@ -84,6 +89,7 @@ public EventCollectorSink(
8489 /// <param name="formatProvider">The format provider used when rendering the message</param>
8590 /// <param name="renderTemplate">Whether to render the message template</param>
8691 /// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
92+ /// <param name="queueLimit">Maximum number of events in the queue</param>
8793 /// <param name="index">The Splunk index to log to</param>
8894 /// <param name="source">The source of the event</param>
8995 /// <param name="sourceType">The source type of the event</param>
@@ -99,6 +105,7 @@ public EventCollectorSink(
99105 string index ,
100106 int batchIntervalInSeconds ,
101107 int batchSizeLimit ,
108+ int ? queueLimit ,
102109 IFormatProvider formatProvider = null ,
103110 bool renderTemplate = true ,
104111 HttpMessageHandler messageHandler = null )
@@ -108,6 +115,7 @@ public EventCollectorSink(
108115 uriPath ,
109116 batchIntervalInSeconds ,
110117 batchSizeLimit ,
118+ queueLimit ,
111119 new SplunkJsonFormatter ( renderTemplate , formatProvider , source , sourceType , host , index ) ,
112120 messageHandler )
113121 {
@@ -120,6 +128,7 @@ public EventCollectorSink(
120128 /// <param name="eventCollectorToken">The token to use when authenticating with the event collector</param>
121129 /// <param name="uriPath">Change the default endpoint of the Event Collector e.g. services/collector/event</param>
122130 /// <param name="batchSizeLimit">The size of the batch when sending to the event collector</param>
131+ /// <param name="queueLimit">Maximum number of events in the queue</param>
123132 /// <param name="formatProvider">The format provider used when rendering the message</param>
124133 /// <param name="renderTemplate">Whether to render the message template</param>
125134 /// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
@@ -140,6 +149,7 @@ public EventCollectorSink(
140149 CustomFields fields ,
141150 int batchIntervalInSeconds ,
142151 int batchSizeLimit ,
152+ int ? queueLimit ,
143153 IFormatProvider formatProvider = null ,
144154 bool renderTemplate = true ,
145155 HttpMessageHandler messageHandler = null )
@@ -150,6 +160,7 @@ public EventCollectorSink(
150160 uriPath ,
151161 batchIntervalInSeconds ,
152162 batchSizeLimit ,
163+ queueLimit ,
153164 new SplunkJsonFormatter ( renderTemplate , formatProvider , source , sourceType , host , index , fields ) ,
154165 messageHandler )
155166 {
@@ -163,6 +174,7 @@ public EventCollectorSink(
163174 /// <param name="uriPath">Change the default endpoint of the Event Collector e.g. services/collector/event</param>
164175 /// <param name="batchSizeLimit">The size of the batch when sending to the event collector</param>
165176 /// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
177+ /// <param name="queueLimit">Maximum number of events in the queue</param>
166178 /// <param name="jsonFormatter">The text formatter used to render log events into a JSON format for consumption by Splunk</param>
167179 /// <param name="messageHandler">The handler used to send HTTP requests</param>
168180 public EventCollectorSink (
@@ -171,9 +183,10 @@ public EventCollectorSink(
171183 string uriPath ,
172184 int batchIntervalInSeconds ,
173185 int batchSizeLimit ,
186+ int ? queueLimit ,
174187 ITextFormatter jsonFormatter ,
175188 HttpMessageHandler messageHandler = null )
176- : base ( batchSizeLimit , TimeSpan . FromSeconds ( batchIntervalInSeconds ) )
189+ : base ( batchSizeLimit , TimeSpan . FromSeconds ( batchIntervalInSeconds ) , queueLimit ?? NoQueueLimit )
177190 {
178191 _uriPath = uriPath ;
179192 _splunkHost = splunkHost ;
0 commit comments