@@ -29,9 +29,9 @@ namespace Serilog.Sinks.Splunk
2929 /// <summary>
3030 /// A sink to log to the Event Collector available in Splunk 6.3
3131 /// </summary>
32- public class EventCollectorSink : PeriodicBatchingSink
32+ public class EventCollectorSink : IBatchedLogEventSink
3333 {
34- private const int DefaultQueueLimit = 100000 ;
34+ internal const int DefaultQueueLimit = 100000 ;
3535
3636 private readonly string _splunkHost ;
3737 private readonly string _uriPath ;
@@ -54,26 +54,17 @@ public class EventCollectorSink : PeriodicBatchingSink
5454 /// </summary>
5555 /// <param name="splunkHost">The host of the Splunk instance with the Event collector configured</param>
5656 /// <param name="eventCollectorToken">The token to use when authenticating with the event collector</param>
57- /// <param name="batchSizeLimit">The size of the batch when sending to the event collector</param>
5857 /// <param name="formatProvider">The format provider used when rendering the message</param>
5958 /// <param name="renderTemplate">Whether to render the message template</param>
60- /// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
61- /// <param name="queueLimit">Maximum number of events in the queue</param>
6259 public EventCollectorSink (
6360 string splunkHost ,
6461 string eventCollectorToken ,
65- int batchIntervalInSeconds = 5 ,
66- int batchSizeLimit = 100 ,
67- int ? queueLimit = null ,
6862 IFormatProvider formatProvider = null ,
6963 bool renderTemplate = true )
7064 : this (
7165 splunkHost ,
7266 eventCollectorToken ,
7367 null , null , null , null , null ,
74- batchIntervalInSeconds ,
75- batchSizeLimit ,
76- queueLimit ,
7768 formatProvider ,
7869 renderTemplate )
7970 {
@@ -85,11 +76,8 @@ public EventCollectorSink(
8576 /// <param name="splunkHost">The host of the Splunk instance with the Event collector configured</param>
8677 /// <param name="eventCollectorToken">The token to use when authenticating with the event collector</param>
8778 /// <param name="uriPath">Change the default endpoint of the Event Collector e.g. services/collector/event</param>
88- /// <param name="batchSizeLimit">The size of the batch when sending to the event collector</param>
8979 /// <param name="formatProvider">The format provider used when rendering the message</param>
9080 /// <param name="renderTemplate">Whether to render the message template</param>
91- /// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
92- /// <param name="queueLimit">Maximum number of events in the queue</param>
9381 /// <param name="index">The Splunk index to log to</param>
9482 /// <param name="source">The source of the event</param>
9583 /// <param name="sourceType">The source type of the event</param>
@@ -103,19 +91,14 @@ public EventCollectorSink(
10391 string sourceType ,
10492 string host ,
10593 string index ,
106- int batchIntervalInSeconds ,
107- int batchSizeLimit ,
108- int ? queueLimit ,
10994 IFormatProvider formatProvider = null ,
11095 bool renderTemplate = true ,
11196 HttpMessageHandler messageHandler = null )
11297 : this (
11398 splunkHost ,
11499 eventCollectorToken ,
115100 uriPath ,
116- batchIntervalInSeconds ,
117- batchSizeLimit ,
118- queueLimit ,
101+
119102 new SplunkJsonFormatter ( renderTemplate , formatProvider , source , sourceType , host , index ) ,
120103 messageHandler )
121104 {
@@ -127,11 +110,8 @@ public EventCollectorSink(
127110 /// <param name="splunkHost">The host of the Splunk instance with the Event collector configured</param>
128111 /// <param name="eventCollectorToken">The token to use when authenticating with the event collector</param>
129112 /// <param name="uriPath">Change the default endpoint of the Event Collector e.g. services/collector/event</param>
130- /// <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>
132113 /// <param name="formatProvider">The format provider used when rendering the message</param>
133114 /// <param name="renderTemplate">Whether to render the message template</param>
134- /// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
135115 /// <param name="index">The Splunk index to log to</param>
136116 /// <param name="fields">Add extra CustomExtraFields for Splunk to index</param>
137117 /// <param name="source">The source of the event</param>
@@ -147,9 +127,6 @@ public EventCollectorSink(
147127 string host ,
148128 string index ,
149129 CustomFields fields ,
150- int batchIntervalInSeconds ,
151- int batchSizeLimit ,
152- int ? queueLimit ,
153130 IFormatProvider formatProvider = null ,
154131 bool renderTemplate = true ,
155132 HttpMessageHandler messageHandler = null )
@@ -158,9 +135,6 @@ public EventCollectorSink(
158135 splunkHost ,
159136 eventCollectorToken ,
160137 uriPath ,
161- batchIntervalInSeconds ,
162- batchSizeLimit ,
163- queueLimit ,
164138 new SplunkJsonFormatter ( renderTemplate , formatProvider , source , sourceType , host , index , fields ) ,
165139 messageHandler )
166140 {
@@ -172,21 +146,14 @@ public EventCollectorSink(
172146 /// <param name="splunkHost">The host of the Splunk instance with the Event collector configured</param>
173147 /// <param name="eventCollectorToken">The token to use when authenticating with the event collector</param>
174148 /// <param name="uriPath">Change the default endpoint of the Event Collector e.g. services/collector/event</param>
175- /// <param name="batchSizeLimit">The size of the batch when sending to the event collector</param>
176- /// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
177- /// <param name="queueLimit">Maximum number of events in the queue</param>
178149 /// <param name="jsonFormatter">The text formatter used to render log events into a JSON format for consumption by Splunk</param>
179150 /// <param name="messageHandler">The handler used to send HTTP requests</param>
180151 public EventCollectorSink (
181152 string splunkHost ,
182153 string eventCollectorToken ,
183154 string uriPath ,
184- int batchIntervalInSeconds ,
185- int batchSizeLimit ,
186- int ? queueLimit ,
187155 ITextFormatter jsonFormatter ,
188156 HttpMessageHandler messageHandler = null )
189- : base ( batchSizeLimit , TimeSpan . FromSeconds ( batchIntervalInSeconds ) , queueLimit ?? DefaultQueueLimit )
190157 {
191158 _uriPath = uriPath ;
192159 _splunkHost = splunkHost ;
@@ -197,14 +164,8 @@ public EventCollectorSink(
197164 : new EventCollectorClient ( eventCollectorToken ) ;
198165 }
199166
200- /// <summary>
201- /// Emit a batch of log events, running asynchronously.
202- /// </summary>
203- /// <param name="events">The events to emit.</param>
204- /// <remarks>
205- /// Override either <see cref="PeriodicBatchingSink.EmitBatch" /> or <see cref="PeriodicBatchingSink.EmitBatchAsync" />, not both.
206- /// </remarks>
207- protected override async Task EmitBatchAsync ( IEnumerable < LogEvent > events )
167+ /// <inheritdoc />
168+ public async Task EmitBatchAsync ( IEnumerable < LogEvent > events )
208169 {
209170 var allEvents = new StringWriter ( ) ;
210171
@@ -233,5 +194,8 @@ protected override async Task EmitBatchAsync(IEnumerable<LogEvent> events)
233194 }
234195 }
235196 }
197+
198+ /// <inheritdoc />
199+ public Task OnEmptyBatchAsync ( ) => Task . CompletedTask ;
236200 }
237201}
0 commit comments