keith-turner commented on code in PR #5398:
URL: https://github.com/apache/accumulo/pull/5398#discussion_r1990287190


##########
core/src/main/java/org/apache/accumulo/core/rpc/AccumuloProtocolFactory.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.core.rpc;
+
+import org.apache.accumulo.core.trace.TraceUtil;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.protocol.TMessage;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TTransport;
+
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.context.Scope;
+
+public class AccumuloProtocolFactory extends TCompactProtocol.Factory {
+
+  private static final long serialVersionUID = 1L;
+
+  private final boolean isClient;
+
+  public static class AccumuloProtocol extends TCompactProtocol {
+
+    private static final int MAGIC_NUMBER = 0x41434355; // "ACCU" in ASCII
+    private static final byte PROTOCOL_VERSION = 1;

Review Comment:
   
   Should probably add a comment to AccumuloDataVersion.CURRENT_VERSION that 
references this and mentions that when changing CURRENT_VERSION may also need 
to change this.



##########
core/src/main/java/org/apache/accumulo/core/rpc/AccumuloProtocolFactory.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.core.rpc;
+
+import org.apache.accumulo.core.trace.TraceUtil;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.protocol.TMessage;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TTransport;
+
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.context.Scope;
+
+public class AccumuloProtocolFactory extends TCompactProtocol.Factory {
+
+  private static final long serialVersionUID = 1L;
+
+  private final boolean isClient;
+
+  public static class AccumuloProtocol extends TCompactProtocol {
+
+    private static final int MAGIC_NUMBER = 0x41434355; // "ACCU" in ASCII
+    private static final byte PROTOCOL_VERSION = 1;
+
+    private final boolean isClient;
+
+    private Span span = null;
+    private Scope scope = null;
+
+    public AccumuloProtocol(TTransport transport, boolean isClient) {
+      super(transport);
+      this.isClient = isClient;
+    }
+
+    @Override
+    public void writeMessageBegin(TMessage message) throws TException {
+      if (this.isClient) {
+        span = TraceUtil.startClientRpcSpan(this.getClass(), message.name);
+        scope = span.makeCurrent();
+
+        try {
+          this.writeHeader();
+        } catch (TException e) {
+          if (scope != null) {

Review Comment:
   span has a recordException message, but not sure if that should be used 
here.  I have seen it but have not looked into it in detail.  Might be worth 
looking into.



##########
core/src/main/java/org/apache/accumulo/core/rpc/AccumuloProtocolFactory.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.core.rpc;
+
+import org.apache.accumulo.core.trace.TraceUtil;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.protocol.TMessage;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TTransport;
+
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.context.Scope;
+
+public class AccumuloProtocolFactory extends TCompactProtocol.Factory {
+
+  private static final long serialVersionUID = 1L;
+
+  private final boolean isClient;
+
+  public static class AccumuloProtocol extends TCompactProtocol {
+
+    private static final int MAGIC_NUMBER = 0x41434355; // "ACCU" in ASCII
+    private static final byte PROTOCOL_VERSION = 1;
+
+    private final boolean isClient;
+
+    private Span span = null;
+    private Scope scope = null;
+
+    public AccumuloProtocol(TTransport transport, boolean isClient) {
+      super(transport);
+      this.isClient = isClient;
+    }
+
+    @Override
+    public void writeMessageBegin(TMessage message) throws TException {
+      if (this.isClient) {
+        span = TraceUtil.startClientRpcSpan(this.getClass(), message.name);
+        scope = span.makeCurrent();
+
+        try {
+          this.writeHeader();
+        } catch (TException e) {
+          if (scope != null) {
+            scope.close();
+          }
+          if (span != null) {
+            span.end();
+          }
+          throw e;
+        }
+      }
+
+      super.writeMessageBegin(message);

Review Comment:
   Seems like this should be inside the try block above.  Thinking if this 
message throws exception that writeMessageEnd will never be called.  If it 
should be in the try block then maybe the existing code in 2.1 has a bug.



-- 
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