Skip to content

Commit eb64191

Browse files
authored
Merge pull request #1008 from microsoft/log-the-reason-for-400-errors
Log the reason for 400 errors
2 parents 3fa5f8e + 1aeab5f commit eb64191

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/main/java/com/microsoft/applicationinsights/internal/channel/common/TransmissionNetworkOutput.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public boolean send(Transmission transmission) {
175175
HttpResponse response = null;
176176
HttpPost request = null;
177177
int code = 0;
178+
String reason = null;
178179
String respString = null;
179180
Throwable ex = null;
180181
Header retryAfterHeader = null;
@@ -185,6 +186,7 @@ public boolean send(Transmission transmission) {
185186
response = httpClient.sendPostRequest(request);
186187
HttpEntity respEntity = response.getEntity();
187188
code = response.getStatusLine().getStatusCode();
189+
reason = response.getStatusLine().getReasonPhrase();
188190
respString = EntityUtils.toString(respEntity);
189191
retryAfterHeader = response.getFirstHeader(RESPONSE_THROTTLING_HEADER);
190192

@@ -235,7 +237,9 @@ public boolean send(Transmission transmission) {
235237
}
236238
httpClient.dispose(response);
237239

238-
if (code != HttpStatus.SC_OK) {
240+
if (code == HttpStatus.SC_BAD_REQUEST) {
241+
InternalLogger.INSTANCE.error("Error sending data: %s", reason);
242+
} else if (code != HttpStatus.SC_OK) {
239243
// Invoke the listeners for handling things like errors
240244
// The listeners will handle the back off logic as well as the dispatch
241245
// operation

0 commit comments

Comments
 (0)