Skip to content

Commit

Permalink
Merge pull request #31 from evilpilaf/http2
Browse files Browse the repository at this point in the history
Add Http2 support
  • Loading branch information
evilpilaf authored Feb 27, 2020
2 parents 0d74cd5 + 4d60a7f commit f39d5bc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Honeycomb.Serilog.Sink/HoneycombSerilogSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ private async Task SendBatchedEvents(string events)
{
var requestMessage = new HttpRequestMessage(HttpMethod.Post, $"/1/batch/{_teamId}")
{
Content = new StringContent(events, Encoding.UTF8, "application/json")
Content = new StringContent(events, Encoding.UTF8, "application/json"),
Version = new Version(2, 0)
};

requestMessage.Headers.Add("X-Honeycomb-Team", _apiKey);
var result = await SendRequest(requestMessage).ConfigureAwait(false);
if (!result.IsSuccessStatusCode)
var response = await SendRequest(requestMessage).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
using (Stream contentStream = await result.Content.ReadAsStreamAsync().ConfigureAwait(false))
using (Stream contentStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
using (var reader = new StreamReader(contentStream))
{
var response = await reader.ReadToEndAsync().ConfigureAwait(false);
SelfLog.WriteLine("Failure sending event to Honeycomb, received {statusCode} response with content {content}", result.StatusCode, response);
var responseContent = await reader.ReadToEndAsync().ConfigureAwait(false);
SelfLog.WriteLine("Failure sending event to Honeycomb, received {statusCode} response with content {content}", response.StatusCode, responseContent);
}
}
}
Expand Down

0 comments on commit f39d5bc

Please sign in to comment.