Skip to content

Commit

Permalink
More bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tippmar-nr committed Aug 17, 2023
1 parent b2ee6d4 commit 968f6ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ public override async Task<IHttpResponse> SendAsync(IHttpRequest request)
//return Task.FromResult((IHttpResponse) new WebRequestClientResponse(request.RequestGuid, resp));
return new WebRequestClientResponse(request.RequestGuid, resp);
}
catch
catch (WebException ex)
{
if (ex.Response is HttpWebResponse httpWebResponse)
return new WebRequestClientResponse(request.RequestGuid, httpWebResponse);

if (_diagnoseConnectionError)
{
DiagnoseConnectionError(request.Uri.Host);
Expand Down
14 changes: 7 additions & 7 deletions src/Agent/NewRelic/Agent/Core/DataTransport/HttpCollectorWire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ public string SendData(string method, ConnectionInfo connectionInfo, string seri

using var response = httpClient.SendAsync(request).GetAwaiter().GetResult();

var responseContent = response.GetContentAsync().GetAwaiter().GetResult();

if (!response.IsSuccessStatusCode)
{
ThrowExceptionFromHttpResponseMessage(serializedData, response.StatusCode, responseContent, requestGuid);
}

DataTransportAuditLogger.Log(DataTransportAuditLogger.AuditLogDirection.Sent, DataTransportAuditLogger.AuditLogSource.InstrumentedApp, request.Uri.ToString());
DataTransportAuditLogger.Log(DataTransportAuditLogger.AuditLogDirection.Sent, DataTransportAuditLogger.AuditLogSource.InstrumentedApp, request.Content.SerializedData);

var responseContent = response.GetContentAsync().GetAwaiter().GetResult();

_agentHealthReporter.ReportSupportabilityDataUsage("Collector", method, request.Content.UncompressedByteCount, new UTF8Encoding().GetBytes(responseContent).Length);

// Possibly combine these logs? makes parsing harder in tests...
Expand All @@ -79,11 +84,6 @@ public string SendData(string method, ConnectionInfo connectionInfo, string seri

DataTransportAuditLogger.Log(DataTransportAuditLogger.AuditLogDirection.Received, DataTransportAuditLogger.AuditLogSource.Collector, responseContent);

if (!response.IsSuccessStatusCode)
{
ThrowExceptionFromHttpResponseMessage(serializedData, response.StatusCode, responseContent, requestGuid);
}

return responseContent;
}
catch (PayloadSizeExceededException)
Expand Down

0 comments on commit 968f6ce

Please sign in to comment.