From 86bc0ae11e28876daefa8451dbaa78975c562426 Mon Sep 17 00:00:00 2001 From: Hailong Wen Date: Fri, 2 Feb 2018 17:38:53 -0800 Subject: [PATCH] Use separate id generator; rename attribute name. --- .../java/com/google/api/client/http/HttpRequest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java b/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java index cfb5b1c1d..8f4c300fc 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java +++ b/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java @@ -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.singletonMap( - "number of retry", + "number", AttributeValue.longAttributeValue(numRetries - retriesRemaining)))); // Cleanup any unneeded response from a previous iteration if (response != null) { @@ -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;