Repository: hbase
Updated Branches:
  refs/heads/branch-2 e962e1ac2 -> 72e6d7c07


HBASE-20245 HTrace commands do not work


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/72e6d7c0
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/72e6d7c0
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/72e6d7c0

Branch: refs/heads/branch-2
Commit: 72e6d7c0732f0f22940f19c74dede40b2f1af362
Parents: e962e1a
Author: Balazs Meszaros <balazs.mesza...@cloudera.com>
Authored: Fri Mar 23 17:02:04 2018 +0100
Committer: Michael Stack <st...@apache.org>
Committed: Fri Mar 23 16:54:06 2018 -0700

----------------------------------------------------------------------
 hbase-shell/src/main/ruby/shell/commands/trace.rb | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/72e6d7c0/hbase-shell/src/main/ruby/shell/commands/trace.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/trace.rb 
b/hbase-shell/src/main/ruby/shell/commands/trace.rb
index b0350be..f2a8ee0 100644
--- a/hbase-shell/src/main/ruby/shell/commands/trace.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/trace.rb
@@ -16,13 +16,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-HTrace = org.apache.htrace.core.Tracer
-java_import org.apache.htrace.core.Sampler
+
 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
+
       def help
         <<-EOF
 Start or Stop tracing using HTrace.
@@ -55,16 +60,19 @@ EOF
         @@receiver ||= SpanReceiverHost.getInstance(@shell.hbase.configuration)
         if startstop == 'start'
           unless tracing?
-            @@tracescope = HTrace.startSpan(spanname, Sampler.ALWAYS)
+            @@tracescope = @@tracer.newScope(spanname)
           end
         elsif startstop == 'stop'
-          @@tracescope.close if tracing?
+          if tracing?
+            @@tracescope.close
+            @@tracescope = nil
+          end
         end
         tracing?
       end
 
       def tracing?
-        HTrace.isTracing
+        @@tracescope != nil
       end
     end
   end

Reply via email to