Skip to content

Commit

Permalink
Use separate id generator; rename attribute name.
Browse files Browse the repository at this point in the history
  • Loading branch information
HailongWen authored and mattwhisenhunt committed Feb 6, 2018
1 parent f26d9da commit 86bc0ae
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -869,14 +869,15 @@ public HttpResponse execute() throws IOException {
.spanBuilder(OpenCensusUtils.SPAN_NAME_HTTP_REQUEST_EXECUTE)
.setRecordEvents(OpenCensusUtils.isRecordEvent())
.startSpan();
long idGenerator = 0L;
long sentIdGenerator = 0L;
long recvIdGenerator = 0L;

do {
span.addAnnotation(
Annotation.fromDescriptionAndAttributes(
"retry",
Collections.<String, AttributeValue>singletonMap(
"number of retry",
"number",
AttributeValue.longAttributeValue(numRetries - retriesRemaining))));
// Cleanup any unneeded response from a previous iteration
if (response != null) {
Expand Down Expand Up @@ -1005,12 +1006,12 @@ public HttpResponse execute() throws IOException {
// switch tracing scope to current span
Scope ws = tracer.withSpan(span);
OpenCensusUtils.recordSentMessageEvent(
span, idGenerator++, lowLevelHttpRequest.getContentLength());
span, sentIdGenerator++, lowLevelHttpRequest.getContentLength());
try {
LowLevelHttpResponse lowLevelHttpResponse = lowLevelHttpRequest.execute();
if (lowLevelHttpResponse != null) {
OpenCensusUtils.recordReceivedMessageEvent(
span, idGenerator++, lowLevelHttpResponse.getContentLength());
span, recvIdGenerator++, lowLevelHttpResponse.getContentLength());
}
// Flag used to indicate if an exception is thrown before the response is constructed.
boolean responseConstructed = false;
Expand Down

0 comments on commit 86bc0ae

Please sign in to comment.