Skip to content
Permalink
Browse files
feat: add http.status_code attribute to all Spans that have at least …
…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 fb02042ac216379820950879cea45d06eec5278c
@@ -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;
@@ -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());

0 comments on commit fb02042

Please sign in to comment.