You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2021/11/12 14:51:59 UTC

[hbase] branch branch-2 updated: HBASE-26432 enable tracing from shell (#3823)

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 4483bf4  HBASE-26432 enable tracing from shell (#3823)
4483bf4 is described below

commit 4483bf43a4c11fcdbc9a152e1bd59e86b440054f
Author: mkkumar <ma...@gmail.com>
AuthorDate: Fri Nov 12 20:19:45 2021 +0530

    HBASE-26432 enable tracing from shell (#3823)
    
    Signed-off-by: Duo Zhang <zh...@apache.org>
    Signed-off-by: Tak Lon (Stephen) Wu <ta...@apache.org>
---
 hbase-shell/src/main/ruby/shell/commands/trace.rb | 44 +++++++++++------------
 1 file changed, 20 insertions(+), 24 deletions(-)

diff --git a/hbase-shell/src/main/ruby/shell/commands/trace.rb b/hbase-shell/src/main/ruby/shell/commands/trace.rb
index f52f474..90c11ae 100644
--- a/hbase-shell/src/main/ruby/shell/commands/trace.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/trace.rb
@@ -17,21 +17,16 @@
 # limitations under the License.
 #
 
-# Disable tracing for now as HTrace does not work any more
-# java_import org.apache.hadoop.hbase.trace.SpanReceiverHost
-
 module Shell
   module Commands
     class Trace < Command
-      # @@conf = org.apache.htrace.core.HTraceConfiguration.fromKeyValuePairs(
-      #  'sampler.classes', 'org.apache.htrace.core.AlwaysSampler'
-      # )
-      # @@tracer = org.apache.htrace.core.Tracer::Builder.new('HBaseShell').conf(@@conf).build()
-      # @@tracescope = nil
+       @@tracer = org.apache.hadoop.hbase.trace.TraceUtil.getGlobalTracer()
+       @@tracespan = nil
+       @@tracescope = nil
 
       def help
         <<-EOF
-Start or Stop tracing using HTrace.
+Start or Stop tracing using OpenTelemetry.
 Always returns true if tracing is running, otherwise false.
 If the first argument is 'start', new span is started.
 If the first argument is 'stop', current running span is stopped.
@@ -58,23 +53,24 @@ EOF
       end
 
       def trace(startstop, spanname)
-        # @@receiver ||= SpanReceiverHost.getInstance(@shell.hbase.configuration)
-        # if startstop == 'start'
-        #   unless tracing?
-        #     @@tracescope = @@tracer.newScope(spanname)
-        #   end
-        # elsif startstop == 'stop'
-        #   if tracing?
-        #    @@tracescope.close
-        #    @@tracescope = nil
-        #   end
-        # end
-        # tracing?
+        if startstop == 'start'
+          unless tracing?
+           @@tracespan = @@tracer.spanBuilder(spanname).startSpan()
+           @@tracescope = @@tracespan.makeCurrent()
+          end
+        elsif startstop == 'stop'
+          if tracing?
+           @@tracescope.close()
+           @@tracespan.end()
+           @@tracescope = nil
+          end
+        end
+        tracing?
       end
 
-      # def tracing?
-      #   @@tracescope != nil
-      # end
+      def tracing?
+        @@tracescope != nil
+      end
     end
   end
 end