Skip to content

Commit 9da74ab

Browse files
feat: add http.status_code attribute to all Spans that have at least a low level http response
Signed-off-by: CI-Bot for Emmanuel Courreges <[email protected]>
1 parent 635c813 commit 9da74ab

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ public HttpResponse execute() throws IOException {
10121012
LowLevelHttpResponse lowLevelHttpResponse = lowLevelHttpRequest.execute();
10131013
if (lowLevelHttpResponse != null) {
10141014
OpenCensusUtils.recordReceivedMessageEvent(span, lowLevelHttpResponse.getContentLength());
1015+
span.putAttribute(HttpTraceAttributeConstants.HTTP_STATUS_CODE, AttributeValue.longAttributeValue(lowLevelHttpResponse.getStatusCode()));
10151016
}
10161017
// Flag used to indicate if an exception is thrown before the response is constructed.
10171018
boolean responseConstructed = false;

google-http-client/src/test/java/com/google/api/client/http/HttpRequestTracingTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public void executeCreatesSpan() throws IOException {
8282
assertAttributeEquals(span, "http.host", "google.com");
8383
assertAttributeEquals(span, "http.url", "https://google.com/");
8484
assertAttributeEquals(span, "http.method", "GET");
85+
assertAttributeEquals(span, "http.status_code", "200");
8586

8687
// Ensure we have a single annotation for starting the first attempt
8788
assertEquals(1, span.getAnnotations().getEvents().size());

0 commit comments

Comments
 (0)