18
18
using System . IO ;
19
19
using System . Linq ;
20
20
using System . Net ;
21
+ using System . Net . Http ;
21
22
using System . Threading ;
22
23
using System . Threading . Tasks ;
23
24
using Serilog . Core ;
@@ -73,7 +74,7 @@ public EventCollectorSink(
73
74
formatProvider ,
74
75
renderTemplate )
75
76
{
76
- }
77
+ }
77
78
78
79
/// <summary>
79
80
/// Creates a new instance of the sink
@@ -89,6 +90,7 @@ public EventCollectorSink(
89
90
/// <param name="source">The source of the event</param>
90
91
/// <param name="sourceType">The source type of the event</param>
91
92
/// <param name="host">The host of the event</param>
93
+ /// <param name="messageHandler">The handler used to send HTTP requests</param>
92
94
public EventCollectorSink (
93
95
string splunkHost ,
94
96
string eventCollectorToken ,
@@ -100,7 +102,8 @@ public EventCollectorSink(
100
102
int batchIntervalInSeconds ,
101
103
int batchSizeLimit ,
102
104
IFormatProvider formatProvider = null ,
103
- bool renderTemplate = true )
105
+ bool renderTemplate = true ,
106
+ HttpMessageHandler messageHandler = null )
104
107
{
105
108
_uriPath = uriPath ;
106
109
_splunkHost = splunkHost ;
@@ -109,7 +112,9 @@ public EventCollectorSink(
109
112
_batchSizeLimitLimit = batchSizeLimit ;
110
113
111
114
var batchInterval = TimeSpan . FromSeconds ( batchIntervalInSeconds ) ;
112
- _httpClient = new EventCollectorClient ( eventCollectorToken ) ;
115
+ _httpClient = messageHandler != null
116
+ ? new EventCollectorClient ( eventCollectorToken , messageHandler )
117
+ : new EventCollectorClient ( eventCollectorToken ) ;
113
118
114
119
var cancellationToken = new CancellationToken ( ) ;
115
120
0 commit comments