HttpURLConnection response code edge case (#4062)

This commit is contained in:
Trask Stalnaker 2021-09-08 07:55:21 -07:00 committed by GitHub
parent 400d99467a
commit 2c044253e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -124,7 +124,12 @@ public class HttpUrlConnectionInstrumentation implements TypeInstrumentation {
// to be consistent with the telemetry for other http clients.
instrumenter().end(httpUrlState.context, connection, responseCode, null);
} else {
instrumenter().end(httpUrlState.context, connection, null, throwable);
instrumenter()
.end(
httpUrlState.context,
connection,
responseCode > 0 ? responseCode : null,
throwable);
}
httpUrlState.finished = true;
} else if (methodName.equals("getInputStream") && responseCode > 0) {