@@ -31,6 +31,8 @@ namespace Serilog.Sinks.Splunk
31
31
/// </summary>
32
32
public class EventCollectorSink : PeriodicBatchingSink
33
33
{
34
+ private const int NoQueueLimit = - 1 ;
35
+
34
36
private readonly string _splunkHost ;
35
37
private readonly string _uriPath ;
36
38
private readonly ITextFormatter _jsonFormatter ;
@@ -56,11 +58,13 @@ public class EventCollectorSink : PeriodicBatchingSink
56
58
/// <param name="formatProvider">The format provider used when rendering the message</param>
57
59
/// <param name="renderTemplate">Whether to render the message template</param>
58
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>
59
62
public EventCollectorSink (
60
63
string splunkHost ,
61
64
string eventCollectorToken ,
62
65
int batchIntervalInSeconds = 5 ,
63
66
int batchSizeLimit = 100 ,
67
+ int ? queueLimit = null ,
64
68
IFormatProvider formatProvider = null ,
65
69
bool renderTemplate = true )
66
70
: this (
@@ -69,6 +73,7 @@ public EventCollectorSink(
69
73
null , null , null , null , null ,
70
74
batchIntervalInSeconds ,
71
75
batchSizeLimit ,
76
+ queueLimit ,
72
77
formatProvider ,
73
78
renderTemplate )
74
79
{
@@ -84,6 +89,7 @@ public EventCollectorSink(
84
89
/// <param name="formatProvider">The format provider used when rendering the message</param>
85
90
/// <param name="renderTemplate">Whether to render the message template</param>
86
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>
87
93
/// <param name="index">The Splunk index to log to</param>
88
94
/// <param name="source">The source of the event</param>
89
95
/// <param name="sourceType">The source type of the event</param>
@@ -99,6 +105,7 @@ public EventCollectorSink(
99
105
string index ,
100
106
int batchIntervalInSeconds ,
101
107
int batchSizeLimit ,
108
+ int ? queueLimit ,
102
109
IFormatProvider formatProvider = null ,
103
110
bool renderTemplate = true ,
104
111
HttpMessageHandler messageHandler = null )
@@ -108,6 +115,7 @@ public EventCollectorSink(
108
115
uriPath ,
109
116
batchIntervalInSeconds ,
110
117
batchSizeLimit ,
118
+ queueLimit ,
111
119
new SplunkJsonFormatter ( renderTemplate , formatProvider , source , sourceType , host , index ) ,
112
120
messageHandler )
113
121
{
@@ -120,6 +128,7 @@ public EventCollectorSink(
120
128
/// <param name="eventCollectorToken">The token to use when authenticating with the event collector</param>
121
129
/// <param name="uriPath">Change the default endpoint of the Event Collector e.g. services/collector/event</param>
122
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>
123
132
/// <param name="formatProvider">The format provider used when rendering the message</param>
124
133
/// <param name="renderTemplate">Whether to render the message template</param>
125
134
/// <param name="batchIntervalInSeconds">The interval in seconds that batching should occur</param>
@@ -140,6 +149,7 @@ public EventCollectorSink(
140
149
CustomFields fields ,
141
150
int batchIntervalInSeconds ,
142
151
int batchSizeLimit ,
152
+ int ? queueLimit ,
143
153
IFormatProvider formatProvider = null ,
144
154
bool renderTemplate = true ,
145
155
HttpMessageHandler messageHandler = null )
@@ -150,6 +160,7 @@ public EventCollectorSink(
150
160
uriPath ,
151
161
batchIntervalInSeconds ,
152
162
batchSizeLimit ,
163
+ queueLimit ,
153
164
new SplunkJsonFormatter ( renderTemplate , formatProvider , source , sourceType , host , index , fields ) ,
154
165
messageHandler )
155
166
{
@@ -163,6 +174,7 @@ public EventCollectorSink(
163
174
/// <param name="uriPath">Change the default endpoint of the Event Collector e.g. services/collector/event</param>
164
175
/// <param name="batchSizeLimit">The size of the batch when sending to the event collector</param>
165
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>
166
178
/// <param name="jsonFormatter">The text formatter used to render log events into a JSON format for consumption by Splunk</param>
167
179
/// <param name="messageHandler">The handler used to send HTTP requests</param>
168
180
public EventCollectorSink (
@@ -171,9 +183,10 @@ public EventCollectorSink(
171
183
string uriPath ,
172
184
int batchIntervalInSeconds ,
173
185
int batchSizeLimit ,
186
+ int ? queueLimit ,
174
187
ITextFormatter jsonFormatter ,
175
188
HttpMessageHandler messageHandler = null )
176
- : base ( batchSizeLimit , TimeSpan . FromSeconds ( batchIntervalInSeconds ) )
189
+ : base ( batchSizeLimit , TimeSpan . FromSeconds ( batchIntervalInSeconds ) , queueLimit ?? NoQueueLimit )
177
190
{
178
191
_uriPath = uriPath ;
179
192
_splunkHost = splunkHost ;
0 commit comments