saintstack commented on a change in pull request #2901:
URL: https://github.com/apache/hbase/pull/2901#discussion_r615960607



##########
File path: bin/hbase
##########
@@ -480,6 +480,11 @@ add_jdk11_deps_to_classpath() {
   done
 }
 
+enable_trace() {
+  agent_jar=$(find lib/trace -type f -name "opentelemetry-javaagent-*")
+  HBASE_OPTS="$HBASE_OPTS -javaagent:$agent_jar $HBASE_TRACE_OPTS"

Review comment:
       It'll just fail if two classes w/ same prefix... that is fine I think 
and shouldn't happen usually.

##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocator.java
##########
@@ -84,64 +96,100 @@ private boolean isMeta(TableName tableName) {
     return TableName.isMetaTableName(tableName);
   }
 
+  private <T> CompletableFuture<T> 
tracedLocationFuture(Supplier<CompletableFuture<T>> action,
+    Function<T, List<String>> getRegionNames, TableName tableName, String 
methodName) {
+    Span span = createTableSpan("AsyncRegionLocator." + methodName, tableName);
+    try (Scope scope = span.makeCurrent()) {
+      CompletableFuture<T> future = action.get();
+      FutureUtils.addListener(future, (resp, error) -> {
+        if (error != null) {
+          TraceUtil.setError(span, error);
+        } else {
+          List<String> regionNames = getRegionNames.apply(resp);
+          if (!regionNames.isEmpty()) {
+            span.setAttribute(REGION_NAMES_KEY, regionNames);
+          }
+          span.setStatus(StatusCode.OK);
+        }
+        span.end();
+      });
+      return future;
+    }
+  }
+
+  private List<String> getRegionName(RegionLocations locs) {
+    List<String> names = new ArrayList<>();
+    for (HRegionLocation loc : locs.getRegionLocations()) {
+      if (loc != null) {
+        names.add(loc.getRegion().getRegionNameAsString());
+      }
+    }

Review comment:
       Great.




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

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


Reply via email to