Skip to content

Commit

Permalink
feat: add http.status_code attribute to all Spans that have at least …
Browse files Browse the repository at this point in the history
…a low level http response (#986)

Signed-off-by: CI-Bot for Emmanuel Courreges <emmanuel.courreges@orange.com>
  • Loading branch information
ecourreges-orange committed Jan 19, 2021
1 parent 21b8bba commit fb02042
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Expand Up @@ -1012,6 +1012,7 @@ public HttpResponse execute() throws IOException {
LowLevelHttpResponse lowLevelHttpResponse = lowLevelHttpRequest.execute();
if (lowLevelHttpResponse != null) {
OpenCensusUtils.recordReceivedMessageEvent(span, lowLevelHttpResponse.getContentLength());
span.putAttribute(HttpTraceAttributeConstants.HTTP_STATUS_CODE, AttributeValue.longAttributeValue(lowLevelHttpResponse.getStatusCode()));
}
// Flag used to indicate if an exception is thrown before the response is constructed.
boolean responseConstructed = false;
Expand Down
Expand Up @@ -80,6 +80,7 @@ public void executeCreatesSpan() throws IOException {
assertAttributeEquals(span, "http.host", "google.com");
assertAttributeEquals(span, "http.url", "https://google.com/");
assertAttributeEquals(span, "http.method", "GET");
assertAttributeEquals(span, "http.status_code", "200");

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

0 comments on commit fb02042

Please sign in to comment.