dlmarion commented on a change in pull request #2259:
URL: https://github.com/apache/accumulo/pull/2259#discussion_r719636913



##########
File path: 
core/src/main/java/org/apache/accumulo/core/rpc/TraceProtocolFactory.java
##########
@@ -39,17 +40,19 @@
   public TProtocol getProtocol(TTransport trans) {
     return new TCompactProtocol(trans) {
       private Span span = null;
+      private Scope scope = null;
 
       @Override
       public void writeMessageBegin(TMessage message) throws TException {
-        span = TraceUtil.createSpan(this.getClass(), "client:" + message.name, 
SpanKind.CLIENT);
-        span.makeCurrent();
+        span = TraceUtil.createSpan(this.getClass(), message.name, 
SpanKind.CLIENT);
+        scope = span.makeCurrent();
         super.writeMessageBegin(message);
       }
 
       @Override
       public void writeMessageEnd() throws TException {
         super.writeMessageEnd();
+        scope.close();
         span.end();

Review comment:
       The normal pattern is that the scope get closed first, then the span:
   ```
       Span span = TraceUtil.createSpan(Merge.class, "start", SpanKind.CLIENT);
       try (Scope scope = span.makeCurrent()) {
         ...
       } catch (Exception ex) {
         TraceUtil.setException(span, ex, true);
         ...
       } finally {
         span.end();
       }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to