@@ -29,9 +29,9 @@ namespace Serilog.Sinks.Splunk
29
29
/// <summary>
30
30
/// A sink to log to the Event Collector available in Splunk 6.3
31
31
/// </summary>
32
- public class EventCollectorSink : PeriodicBatchingSink
32
+ public class EventCollectorSink : IBatchedLogEventSink
33
33
{
34
- private const int DefaultQueueLimit = 100000 ;
34
+ internal const int DefaultQueueLimit = 100000 ;
35
35
36
36
private readonly string _splunkHost ;
37
37
private readonly string _uriPath ;
@@ -54,26 +54,17 @@ public class EventCollectorSink : PeriodicBatchingSink
54
54
/// </summary>
55
55
/// <param name="splunkHost">The host of the Splunk instance with the Event collector configured</param>
56
56
/// <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>
58
57
/// <param name="formatProvider">The format provider used when rendering the message</param>
59
58
/// <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>
62
59
public EventCollectorSink (
63
60
string splunkHost ,
64
61
string eventCollectorToken ,
65
- int batchIntervalInSeconds = 5 ,
66
- int batchSizeLimit = 100 ,
67
- int ? queueLimit = null ,
68
62
IFormatProvider formatProvider = null ,
69
63
bool renderTemplate = true )
70
64
: this (
71
65
splunkHost ,
72
66
eventCollectorToken ,
73
67
null , null , null , null , null ,
74
- batchIntervalInSeconds ,
75
- batchSizeLimit ,
76
- queueLimit ,
77
68
formatProvider ,
78
69
renderTemplate )
79
70
{
@@ -85,11 +76,8 @@ public EventCollectorSink(
85
76
/// <param name="splunkHost">The host of the Splunk instance with the Event collector configured</param>
86
77
/// <param name="eventCollectorToken">The token to use when authenticating with the event collector</param>
87
78
/// <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>
89
79
/// <param name="formatProvider">The format provider used when rendering the message</param>
90
80
/// <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>
93
81
/// <param name="index">The Splunk index to log to</param>
94
82
/// <param name="source">The source of the event</param>
95
83
/// <param name="sourceType">The source type of the event</param>
@@ -103,19 +91,14 @@ public EventCollectorSink(
103
91
string sourceType ,
104
92
string host ,
105
93
string index ,
106
- int batchIntervalInSeconds ,
107
- int batchSizeLimit ,
108
- int ? queueLimit ,
109
94
IFormatProvider formatProvider = null ,
110
95
bool renderTemplate = true ,
111
96
HttpMessageHandler messageHandler = null )
112
97
: this (
113
98
splunkHost ,
114
99
eventCollectorToken ,
115
100
uriPath ,
116
- batchIntervalInSeconds ,
117
- batchSizeLimit ,
118
- queueLimit ,
101
+
119
102
new SplunkJsonFormatter ( renderTemplate , formatProvider , source , sourceType , host , index ) ,
120
103
messageHandler )
121
104
{
@@ -127,11 +110,8 @@ public EventCollectorSink(
127
110
/// <param name="splunkHost">The host of the Splunk instance with the Event collector configured</param>
128
111
/// <param name="eventCollectorToken">The token to use when authenticating with the event collector</param>
129
112
/// <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>
132
113
/// <param name="formatProvider">The format provider used when rendering the message</param>
133
114
/// <param name="renderTemplate">Whether to render the message template</param>
134
- /// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
135
115
/// <param name="index">The Splunk index to log to</param>
136
116
/// <param name="fields">Add extra CustomExtraFields for Splunk to index</param>
137
117
/// <param name="source">The source of the event</param>
@@ -147,9 +127,6 @@ public EventCollectorSink(
147
127
string host ,
148
128
string index ,
149
129
CustomFields fields ,
150
- int batchIntervalInSeconds ,
151
- int batchSizeLimit ,
152
- int ? queueLimit ,
153
130
IFormatProvider formatProvider = null ,
154
131
bool renderTemplate = true ,
155
132
HttpMessageHandler messageHandler = null )
@@ -158,9 +135,6 @@ public EventCollectorSink(
158
135
splunkHost ,
159
136
eventCollectorToken ,
160
137
uriPath ,
161
- batchIntervalInSeconds ,
162
- batchSizeLimit ,
163
- queueLimit ,
164
138
new SplunkJsonFormatter ( renderTemplate , formatProvider , source , sourceType , host , index , fields ) ,
165
139
messageHandler )
166
140
{
@@ -172,21 +146,14 @@ public EventCollectorSink(
172
146
/// <param name="splunkHost">The host of the Splunk instance with the Event collector configured</param>
173
147
/// <param name="eventCollectorToken">The token to use when authenticating with the event collector</param>
174
148
/// <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>
178
149
/// <param name="jsonFormatter">The text formatter used to render log events into a JSON format for consumption by Splunk</param>
179
150
/// <param name="messageHandler">The handler used to send HTTP requests</param>
180
151
public EventCollectorSink (
181
152
string splunkHost ,
182
153
string eventCollectorToken ,
183
154
string uriPath ,
184
- int batchIntervalInSeconds ,
185
- int batchSizeLimit ,
186
- int ? queueLimit ,
187
155
ITextFormatter jsonFormatter ,
188
156
HttpMessageHandler messageHandler = null )
189
- : base ( batchSizeLimit , TimeSpan . FromSeconds ( batchIntervalInSeconds ) , queueLimit ?? DefaultQueueLimit )
190
157
{
191
158
_uriPath = uriPath ;
192
159
_splunkHost = splunkHost ;
@@ -197,14 +164,8 @@ public EventCollectorSink(
197
164
: new EventCollectorClient ( eventCollectorToken ) ;
198
165
}
199
166
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 )
208
169
{
209
170
var allEvents = new StringWriter ( ) ;
210
171
@@ -233,5 +194,8 @@ protected override async Task EmitBatchAsync(IEnumerable<LogEvent> events)
233
194
}
234
195
}
235
196
}
197
+
198
+ /// <inheritdoc />
199
+ public Task OnEmptyBatchAsync ( ) => Task . CompletedTask ;
236
200
}
237
201
}
0 commit comments