You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/02/26 04:44:52 UTC

[GitHub] [hbase] jojochuang opened a new pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)

jojochuang opened a new pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)
URL: https://github.com/apache/hbase/pull/1210
 
 
   This is a straightforward API migration, plus, merge HBASE-23758 (Propagate trace context to server correctly) into this patch.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [hbase] jojochuang commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)

Posted by GitBox <gi...@apache.org>.
jojochuang commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)
URL: https://github.com/apache/hbase/pull/1210#discussion_r386732569
 
 

 ##########
 File path: hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java
 ##########
 @@ -17,103 +17,169 @@
  */
 package org.apache.hadoop.hbase.trace;
 
+import io.opentracing.Scope;
+import io.opentracing.SpanContext;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.Span;
+import io.opentracing.SpanContext;
+import io.opentracing.Tracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.util.GlobalTracer;
+import org.apache.commons.codec.binary.Hex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.htrace.core.HTraceConfiguration;
 import org.apache.htrace.core.Sampler;
-import org.apache.htrace.core.Span;
 import org.apache.htrace.core.SpanReceiver;
 import org.apache.htrace.core.TraceScope;
-import org.apache.htrace.core.Tracer;
+import io.jaegertracing.Configuration.SamplerConfiguration;
+
+import org.apache.hadoop.tracing.TraceUtils;
+import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This wrapper class provides functions for accessing htrace 4+ functionality in a simplified way.
  */
 @InterfaceAudience.Private
 public final class TraceUtil {
-  private static HTraceConfiguration conf;
-  private static Tracer tracer;
+  static final Logger LOG = LoggerFactory.getLogger(TraceUtils.class);
+
+  private static io.jaegertracing.Configuration conf;
+  private static io.opentracing.Tracer tracer;
+
+  public static final String HBASE_OPENTRACING_TRACER = "hbase.opentracing.tracer";
+  public static final String HBASE_OPENTRACING_TRACER_DEFAULT = "jaeger";
+  public static final String HBASE_OPENTRACING_MOCKTRACER = "mock";
 
   private TraceUtil() {
   }
 
-  public static void initTracer(Configuration c) {
-    if (c != null) {
-      conf = new HBaseHTraceConfiguration(c);
+  public static void initTracer(Configuration c, String serviceName) {
+    if (GlobalTracer.isRegistered()) {
+      LOG.info("A tracer is already registered.");
+      return;
     }
 
-    if (tracer == null && conf != null) {
-      tracer = new Tracer.Builder("Tracer").conf(conf).build();
+    switch(c.get(HBASE_OPENTRACING_TRACER, HBASE_OPENTRACING_TRACER_DEFAULT)) {
+    case HBASE_OPENTRACING_TRACER_DEFAULT:
+      io.jaegertracing.Configuration conf = io.jaegertracing.Configuration.fromEnv(serviceName);
+      tracer = conf.getTracerBuilder().build();
+      break;
+    case HBASE_OPENTRACING_MOCKTRACER:
+      tracer = new MockTracer();
+      break;
+    default:
+      throw new RuntimeException("Unexpected tracer");
     }
+
+
+    GlobalTracer.register(tracer);
 
 Review comment:
   Yeah make sense to me. I wanted to use GlobalTracer originally because I wanted to make coprocessors, like Phoenix to work. But maintaining a global tracer reference inside HBase should also work (need to use reflection but that's fine)

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [hbase] ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)

Posted by GitBox <gi...@apache.org>.
ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)
URL: https://github.com/apache/hbase/pull/1210#discussion_r386890589
 
 

 ##########
 File path: hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java
 ##########
 @@ -17,103 +17,169 @@
  */
 package org.apache.hadoop.hbase.trace;
 
+import io.opentracing.Scope;
+import io.opentracing.SpanContext;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.Span;
+import io.opentracing.SpanContext;
+import io.opentracing.Tracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.util.GlobalTracer;
+import org.apache.commons.codec.binary.Hex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.htrace.core.HTraceConfiguration;
 import org.apache.htrace.core.Sampler;
-import org.apache.htrace.core.Span;
 import org.apache.htrace.core.SpanReceiver;
 import org.apache.htrace.core.TraceScope;
-import org.apache.htrace.core.Tracer;
+import io.jaegertracing.Configuration.SamplerConfiguration;
+
+import org.apache.hadoop.tracing.TraceUtils;
+import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This wrapper class provides functions for accessing htrace 4+ functionality in a simplified way.
  */
 @InterfaceAudience.Private
 public final class TraceUtil {
-  private static HTraceConfiguration conf;
-  private static Tracer tracer;
+  static final Logger LOG = LoggerFactory.getLogger(TraceUtils.class);
+
+  private static io.jaegertracing.Configuration conf;
+  private static io.opentracing.Tracer tracer;
+
+  public static final String HBASE_OPENTRACING_TRACER = "hbase.opentracing.tracer";
+  public static final String HBASE_OPENTRACING_TRACER_DEFAULT = "jaeger";
+  public static final String HBASE_OPENTRACING_MOCKTRACER = "mock";
 
   private TraceUtil() {
   }
 
-  public static void initTracer(Configuration c) {
-    if (c != null) {
-      conf = new HBaseHTraceConfiguration(c);
+  public static void initTracer(Configuration c, String serviceName) {
+    if (GlobalTracer.isRegistered()) {
+      LOG.info("A tracer is already registered.");
+      return;
     }
 
-    if (tracer == null && conf != null) {
-      tracer = new Tracer.Builder("Tracer").conf(conf).build();
+    switch(c.get(HBASE_OPENTRACING_TRACER, HBASE_OPENTRACING_TRACER_DEFAULT)) {
+    case HBASE_OPENTRACING_TRACER_DEFAULT:
+      io.jaegertracing.Configuration conf = io.jaegertracing.Configuration.fromEnv(serviceName);
+      tracer = conf.getTracerBuilder().build();
+      break;
+    case HBASE_OPENTRACING_MOCKTRACER:
+      tracer = new MockTracer();
+      break;
+    default:
+      throw new RuntimeException("Unexpected tracer");
     }
+
+
+    GlobalTracer.register(tracer);
 
 Review comment:
   One more question - suppose I want to store my traces to some storage - I know Jaeger supports Cassandra and Elastic search backends but that is not exposed to us - so that we can have our own way of backend storage like even dumping to a local file? or say even in hbase system table itself? Is there any thoughts or future plans for this  support ?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [hbase] ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)

Posted by GitBox <gi...@apache.org>.
ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)
URL: https://github.com/apache/hbase/pull/1210#discussion_r385668890
 
 

 ##########
 File path: hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java
 ##########
 @@ -17,103 +17,169 @@
  */
 package org.apache.hadoop.hbase.trace;
 
+import io.opentracing.Scope;
+import io.opentracing.SpanContext;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.Span;
+import io.opentracing.SpanContext;
+import io.opentracing.Tracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.util.GlobalTracer;
+import org.apache.commons.codec.binary.Hex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.htrace.core.HTraceConfiguration;
 import org.apache.htrace.core.Sampler;
-import org.apache.htrace.core.Span;
 import org.apache.htrace.core.SpanReceiver;
 import org.apache.htrace.core.TraceScope;
-import org.apache.htrace.core.Tracer;
+import io.jaegertracing.Configuration.SamplerConfiguration;
+
+import org.apache.hadoop.tracing.TraceUtils;
+import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This wrapper class provides functions for accessing htrace 4+ functionality in a simplified way.
  */
 @InterfaceAudience.Private
 public final class TraceUtil {
-  private static HTraceConfiguration conf;
-  private static Tracer tracer;
+  static final Logger LOG = LoggerFactory.getLogger(TraceUtils.class);
+
+  private static io.jaegertracing.Configuration conf;
+  private static io.opentracing.Tracer tracer;
+
+  public static final String HBASE_OPENTRACING_TRACER = "hbase.opentracing.tracer";
+  public static final String HBASE_OPENTRACING_TRACER_DEFAULT = "jaeger";
+  public static final String HBASE_OPENTRACING_MOCKTRACER = "mock";
 
   private TraceUtil() {
   }
 
-  public static void initTracer(Configuration c) {
-    if (c != null) {
-      conf = new HBaseHTraceConfiguration(c);
+  public static void initTracer(Configuration c, String serviceName) {
+    if (GlobalTracer.isRegistered()) {
+      LOG.info("A tracer is already registered.");
+      return;
     }
 
-    if (tracer == null && conf != null) {
-      tracer = new Tracer.Builder("Tracer").conf(conf).build();
+    switch(c.get(HBASE_OPENTRACING_TRACER, HBASE_OPENTRACING_TRACER_DEFAULT)) {
+    case HBASE_OPENTRACING_TRACER_DEFAULT:
+      io.jaegertracing.Configuration conf = io.jaegertracing.Configuration.fromEnv(serviceName);
+      tracer = conf.getTracerBuilder().build();
+      break;
+    case HBASE_OPENTRACING_MOCKTRACER:
+      tracer = new MockTracer();
+      break;
+    default:
+      throw new RuntimeException("Unexpected tracer");
     }
+
+
+    GlobalTracer.register(tracer);
 
 Review comment:
   I  believe instead of going this way of using GlobalTracer - we should maintain the tracer reference without registering it. So that if we have a method like convert() or uninitTracer() we can use the TraceResolver/TraceConverter to change the tracer impl to a Noop one. If it is registered via GlobalTracer there is no way to do it. Correct me if am wrong here. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [hbase] jojochuang commented on issue #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)

Posted by GitBox <gi...@apache.org>.
jojochuang commented on issue #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)
URL: https://github.com/apache/hbase/pull/1210#issuecomment-591236141
 
 
   Like PR #1202  this one's not going to compile for now.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [hbase] ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)

Posted by GitBox <gi...@apache.org>.
ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)
URL: https://github.com/apache/hbase/pull/1210#discussion_r394828407
 
 

 ##########
 File path: hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java
 ##########
 @@ -17,103 +17,169 @@
  */
 package org.apache.hadoop.hbase.trace;
 
+import io.opentracing.Scope;
+import io.opentracing.SpanContext;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.Span;
+import io.opentracing.SpanContext;
+import io.opentracing.Tracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.util.GlobalTracer;
+import org.apache.commons.codec.binary.Hex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.htrace.core.HTraceConfiguration;
 import org.apache.htrace.core.Sampler;
-import org.apache.htrace.core.Span;
 import org.apache.htrace.core.SpanReceiver;
 import org.apache.htrace.core.TraceScope;
-import org.apache.htrace.core.Tracer;
+import io.jaegertracing.Configuration.SamplerConfiguration;
+
+import org.apache.hadoop.tracing.TraceUtils;
+import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This wrapper class provides functions for accessing htrace 4+ functionality in a simplified way.
  */
 @InterfaceAudience.Private
 public final class TraceUtil {
-  private static HTraceConfiguration conf;
-  private static Tracer tracer;
+  static final Logger LOG = LoggerFactory.getLogger(TraceUtils.class);
+
+  private static io.jaegertracing.Configuration conf;
+  private static io.opentracing.Tracer tracer;
+
+  public static final String HBASE_OPENTRACING_TRACER = "hbase.opentracing.tracer";
+  public static final String HBASE_OPENTRACING_TRACER_DEFAULT = "jaeger";
+  public static final String HBASE_OPENTRACING_MOCKTRACER = "mock";
 
   private TraceUtil() {
   }
 
-  public static void initTracer(Configuration c) {
-    if (c != null) {
-      conf = new HBaseHTraceConfiguration(c);
+  public static void initTracer(Configuration c, String serviceName) {
+    if (GlobalTracer.isRegistered()) {
+      LOG.info("A tracer is already registered.");
+      return;
     }
 
-    if (tracer == null && conf != null) {
-      tracer = new Tracer.Builder("Tracer").conf(conf).build();
+    switch(c.get(HBASE_OPENTRACING_TRACER, HBASE_OPENTRACING_TRACER_DEFAULT)) {
+    case HBASE_OPENTRACING_TRACER_DEFAULT:
+      io.jaegertracing.Configuration conf = io.jaegertracing.Configuration.fromEnv(serviceName);
+      tracer = conf.getTracerBuilder().build();
+      break;
+    case HBASE_OPENTRACING_MOCKTRACER:
+      tracer = new MockTracer();
+      break;
+    default:
+      throw new RuntimeException("Unexpected tracer");
     }
+
+
+    GlobalTracer.register(tracer);
 
 Review comment:
   @jojochuang  - any updates here? Does the Open-telemetry support better logging? I can try that anyway with some sample code. But do you have any heads up on that?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [hbase] Apache-HBase commented on issue #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)

Posted by GitBox <gi...@apache.org>.
Apache-HBase commented on issue #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)
URL: https://github.com/apache/hbase/pull/1210#issuecomment-591260477
 
 
   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime | Comment |
   |:----:|----------:|--------:|:--------|
   | +0 :ok: |  reexec  |   3m  5s |  Docker mode activated.  |
   ||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  1s |  No case conflicting files found.  |
   | +0 :ok: |  prototool  |   0m  0s |  prototool was not available.  |
   | +1 :green_heart: |  hbaseanti  |   0m  0s |  Patch does not have any anti-patterns.  |
   | +1 :green_heart: |  @author  |   0m  0s |  The patch does not contain any @author tags.  |
   | +1 :green_heart: |  test4tests  |   0m  0s |  The patch appears to include 9 new or modified test files.  |
   ||| _ master Compile Tests _ |
   | +0 :ok: |  mvndep  |   1m  3s |  Maven dependency ordering for branch  |
   | +1 :green_heart: |  mvninstall  |   8m 24s |  master passed  |
   | +1 :green_heart: |  compile  |   4m 50s |  master passed  |
   | +1 :green_heart: |  checkstyle  |   3m 15s |  master passed  |
   | +1 :green_heart: |  shadedjars  |   5m 15s |  branch has no errors when building our shaded downstream artifacts.  |
   | +1 :green_heart: |  javadoc  |  10m  7s |  master passed  |
   | +0 :ok: |  spotbugs  |   0m 29s |  Used deprecated FindBugs config; considering switching to SpotBugs.  |
   | +0 :ok: |  findbugs  |   0m 45s |  branch/hbase-shaded no findbugs output file (findbugsXml.xml)  |
   | +0 :ok: |  findbugs  |   0m 17s |  branch/hbase-shaded/hbase-shaded-client no findbugs output file (findbugsXml.xml)  |
   | +0 :ok: |  findbugs  |   0m 11s |  branch/hbase-shaded/hbase-shaded-with-hadoop-check-invariants no findbugs output file (findbugsXml.xml)  |
   | +0 :ok: |  findbugs  |   0m 20s |  branch/hbase-shaded/hbase-shaded-check-invariants no findbugs output file (findbugsXml.xml)  |
   | +0 :ok: |  findbugs  |   0m 29s |  branch/hbase-shaded/hbase-shaded-testing-util no findbugs output file (findbugsXml.xml)  |
   | -0 :warning: |  patch  |   2m 34s |  Used diff version of patch file. Binary files and potentially other changes not applied. Please rebase and squash commits if necessary.  |
   ||| _ Patch Compile Tests _ |
   | +0 :ok: |  mvndep  |   0m 17s |  Maven dependency ordering for patch  |
   | -1 :x: |  mvninstall  |   0m 31s |  root in the patch failed.  |
   | -1 :x: |  compile  |   0m 12s |  root in the patch failed.  |
   | -1 :x: |  cc  |   0m 12s |  root in the patch failed.  |
   | -1 :x: |  javac  |   0m 12s |  root in the patch failed.  |
   | -1 :x: |  checkstyle  |   0m 11s |  The patch fails to run checkstyle in root  |
   | +1 :green_heart: |  whitespace  |   0m  0s |  The patch has no whitespace issues.  |
   | +1 :green_heart: |  xml  |   0m 11s |  The patch has no ill-formed XML file.  |
   | -1 :x: |  shadedjars  |   0m 29s |  patch has 11 errors when building our shaded downstream artifacts.  |
   | -1 :x: |  hadoopcheck  |   0m 12s |  The patch causes 10 errors with Hadoop v2.8.5.  |
   | -1 :x: |  hadoopcheck  |   0m 22s |  The patch causes 10 errors with Hadoop v2.9.2.  |
   | -1 :x: |  hadoopcheck  |   0m 33s |  The patch causes 10 errors with Hadoop v3.1.2.  |
   | -1 :x: |  hbaseprotoc  |   0m 12s |  hbase-shaded in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m 14s |  root in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m  8s |  hbase-client in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m  8s |  hbase-common in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m  9s |  hbase-external-blockcache in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m  9s |  hbase-it in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m  9s |  hbase-mapreduce in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m  8s |  hbase-protocol-shaded in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m  9s |  hbase-server in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m  8s |  hbase-shaded-client in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m  9s |  hbase-shaded-testing-util in the patch failed.  |
   | -1 :x: |  hbaseprotoc  |   0m 10s |  hbase-zookeeper in the patch failed.  |
   | -1 :x: |  javadoc  |   0m 10s |  hbase-shaded in the patch failed.  |
   | -1 :x: |  javadoc  |   0m 10s |  root in the patch failed.  |
   | -1 :x: |  javadoc  |   0m  8s |  hbase-client in the patch failed.  |
   | -1 :x: |  javadoc  |   0m  8s |  hbase-common in the patch failed.  |
   | -1 :x: |  javadoc  |   0m  8s |  hbase-external-blockcache in the patch failed.  |
   | -1 :x: |  javadoc  |   0m  8s |  hbase-it in the patch failed.  |
   | -1 :x: |  javadoc  |   0m 10s |  hbase-mapreduce in the patch failed.  |
   | -1 :x: |  javadoc  |   0m  7s |  hbase-protocol-shaded in the patch failed.  |
   | -1 :x: |  javadoc  |   0m  9s |  hbase-server in the patch failed.  |
   | -1 :x: |  javadoc  |   0m  8s |  hbase-shaded-client in the patch failed.  |
   | -1 :x: |  javadoc  |   0m  8s |  hbase-shaded-testing-util in the patch failed.  |
   | -1 :x: |  javadoc  |   0m  8s |  hbase-zookeeper in the patch failed.  |
   | -1 :x: |  findbugs  |   0m 11s |  hbase-shaded in the patch failed.  |
   | -1 :x: |  findbugs  |   0m 12s |  root in the patch failed.  |
   | -1 :x: |  findbugs  |   0m  8s |  hbase-client in the patch failed.  |
   | -1 :x: |  findbugs  |   0m  8s |  hbase-common in the patch failed.  |
   | -1 :x: |  findbugs  |   0m  8s |  hbase-external-blockcache in the patch failed.  |
   | -1 :x: |  findbugs  |   0m  8s |  hbase-mapreduce in the patch failed.  |
   | -1 :x: |  findbugs  |   0m  7s |  hbase-protocol-shaded in the patch failed.  |
   | -1 :x: |  findbugs  |   0m  9s |  hbase-server in the patch failed.  |
   | +0 :ok: |  findbugs  |   0m 10s |  hbase-shaded/hbase-shaded-check-invariants has no data from findbugs  |
   | -1 :x: |  findbugs  |   0m  8s |  hbase-shaded-client in the patch failed.  |
   | -1 :x: |  findbugs  |   0m  8s |  hbase-shaded-testing-util in the patch failed.  |
   | +0 :ok: |  findbugs  |   0m 10s |  hbase-shaded/hbase-shaded-with-hadoop-check-invariants has no data from findbugs  |
   | -1 :x: |  findbugs  |   0m  8s |  hbase-zookeeper in the patch failed.  |
   ||| _ Other Tests _ |
   | -1 :x: |  unit  |   0m 29s |  root in the patch failed.  |
   | -1 :x: |  asflicense  |   2m 13s |  The patch generated 3 ASF License warnings.  |
   |  |   |  89m 18s |   |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | Client=19.03.6 Server=19.03.6 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/Dockerfile |
   | GITHUB PR | https://github.com/apache/hbase/pull/1210 |
   | Optional Tests | dupname asflicense checkstyle xml javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti compile cc hbaseprotoc prototool |
   | uname | Linux 30613ffa6fc7 4.15.0-74-generic #84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | /home/jenkins/jenkins-slave/workspace/Base-PreCommit-GitHub-PR_PR-1210/out/precommit/personality/provided.sh |
   | git revision | master / ecbed33092 |
   | Default Java | 1.8.0_181 |
   | mvninstall | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-mvninstall-root.txt |
   | compile | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-compile-root.txt |
   | cc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-compile-root.txt |
   | javac | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-compile-root.txt |
   | checkstyle | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out//home/jenkins/jenkins-slave/workspace/Base-PreCommit-GitHub-PR_PR-1210/out/maven-patch-checkstyle-root.txt |
   | shadedjars | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-shadedjars.txt |
   | hadoopcheck | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javac-2.8.5.txt |
   | hadoopcheck | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javac-2.9.2.txt |
   | hadoopcheck | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javac-3.1.2.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-shaded.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-root.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-client.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-common.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-external-blockcache.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-it.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-mapreduce.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-protocol-shaded.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-server.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-shaded_hbase-shaded-client.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-shaded_hbase-shaded-testing-util.txt |
   | hbaseprotoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-hbaseprotoc-hbase-zookeeper.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-shaded.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-root.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-client.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-common.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-external-blockcache.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-it.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-mapreduce.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-protocol-shaded.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-server.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-shaded_hbase-shaded-client.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-shaded_hbase-shaded-testing-util.txt |
   | javadoc | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-javadoc-hbase-zookeeper.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-shaded.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-root.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-client.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-common.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-external-blockcache.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-mapreduce.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-protocol-shaded.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-server.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-shaded_hbase-shaded-client.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-shaded_hbase-shaded-testing-util.txt |
   | findbugs | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-findbugs-hbase-zookeeper.txt |
   | unit | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-unit-root.txt |
   |  Test Results | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/testReport/ |
   | asflicense | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/artifact/out/patch-asflicense-problems.txt |
   | Max. process+thread count | 86 (vs. ulimit of 10000) |
   | modules | C: hbase-protocol hbase-shaded . hbase-client hbase-common hbase-external-blockcache hbase-it hbase-mapreduce hbase-protocol-shaded hbase-server hbase-shaded/hbase-shaded-check-invariants hbase-shaded/hbase-shaded-client hbase-shaded/hbase-shaded-testing-util hbase-shaded/hbase-shaded-with-hadoop-check-invariants hbase-zookeeper U: . |
   | Console output | https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-1210/1/console |
   | versions | git=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11 |
   | Powered by | Apache Yetus 0.11.1 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [hbase] ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)

Posted by GitBox <gi...@apache.org>.
ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)
URL: https://github.com/apache/hbase/pull/1210#discussion_r385635251
 
 

 ##########
 File path: hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java
 ##########
 @@ -17,103 +17,169 @@
  */
 package org.apache.hadoop.hbase.trace;
 
+import io.opentracing.Scope;
+import io.opentracing.SpanContext;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.Span;
+import io.opentracing.SpanContext;
+import io.opentracing.Tracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.util.GlobalTracer;
+import org.apache.commons.codec.binary.Hex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.htrace.core.HTraceConfiguration;
 import org.apache.htrace.core.Sampler;
-import org.apache.htrace.core.Span;
 import org.apache.htrace.core.SpanReceiver;
 import org.apache.htrace.core.TraceScope;
-import org.apache.htrace.core.Tracer;
+import io.jaegertracing.Configuration.SamplerConfiguration;
+
+import org.apache.hadoop.tracing.TraceUtils;
+import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This wrapper class provides functions for accessing htrace 4+ functionality in a simplified way.
  */
 @InterfaceAudience.Private
 public final class TraceUtil {
-  private static HTraceConfiguration conf;
-  private static Tracer tracer;
+  static final Logger LOG = LoggerFactory.getLogger(TraceUtils.class);
+
+  private static io.jaegertracing.Configuration conf;
+  private static io.opentracing.Tracer tracer;
+
+  public static final String HBASE_OPENTRACING_TRACER = "hbase.opentracing.tracer";
+  public static final String HBASE_OPENTRACING_TRACER_DEFAULT = "jaeger";
+  public static final String HBASE_OPENTRACING_MOCKTRACER = "mock";
 
   private TraceUtil() {
   }
 
-  public static void initTracer(Configuration c) {
-    if (c != null) {
-      conf = new HBaseHTraceConfiguration(c);
+  public static void initTracer(Configuration c, String serviceName) {
+    if (GlobalTracer.isRegistered()) {
+      LOG.info("A tracer is already registered.");
+      return;
     }
 
-    if (tracer == null && conf != null) {
-      tracer = new Tracer.Builder("Tracer").conf(conf).build();
+    switch(c.get(HBASE_OPENTRACING_TRACER, HBASE_OPENTRACING_TRACER_DEFAULT)) {
+    case HBASE_OPENTRACING_TRACER_DEFAULT:
+      io.jaegertracing.Configuration conf = io.jaegertracing.Configuration.fromEnv(serviceName);
+      tracer = conf.getTracerBuilder().build();
+      break;
+    case HBASE_OPENTRACING_MOCKTRACER:
+      tracer = new MockTracer();
+      break;
+    default:
+      throw new RuntimeException("Unexpected tracer");
     }
+
+
+    GlobalTracer.register(tracer);
+
+  }
+
+  /*@VisibleForTesting
+  public static void registerTracerForTest(Tracer tracer) {
+    TraceUtil.tracer = tracer;
+    GlobalTracer.register(tracer);
+  }*/
+
+  public static Tracer getTracer() {
+    return tracer;
   }
 
   /**
-   * Wrapper method to create new TraceScope with the given description
-   * @return TraceScope or null when not tracing
+   * Wrapper method to create new Scope with the given description
+   * @return Scope or null when not tracing
    */
-  public static TraceScope createTrace(String description) {
-    return (tracer == null) ? null : tracer.newScope(description);
+  public static Scope createTrace(String description) {
+    return (tracer == null) ? null :
+        tracer.buildSpan(description).startActive(true);
   }
 
   /**
-   * Wrapper method to create new child TraceScope with the given description
+   * Wrapper method to create new child Scope with the given description
    * and parent scope's spanId
    * @param span parent span
-   * @return TraceScope or null when not tracing
+   * @return Scope or null when not tracing
    */
-  public static TraceScope createTrace(String description, Span span) {
-    if (span == null) {
-      return createTrace(description);
-    }
+  public static Scope createTrace(String description, Span span) {
+    if(span == null) return createTrace(description);
+
+    return (tracer == null) ? null : tracer.buildSpan(description).
+        asChildOf(span).startActive(true);
+  }
+
+  public static Scope createTrace(String description, SpanContext spanContext) {
+    if(spanContext == null) return createTrace(description);
 
-    return (tracer == null) ? null : tracer.newScope(description, span.getSpanId());
+    return (tracer == null) ? null : tracer.buildSpan(description).
+        asChildOf(spanContext).startActive(true);
   }
 
   /**
    * Wrapper method to add new sampler to the default tracer
    * @return true if added, false if it was already added
    */
-  public static boolean addSampler(Sampler sampler) {
+  public static boolean addSampler(SamplerConfiguration sampler) {
     if (sampler == null) {
       return false;
     }
 
-    return (tracer == null) ? false : tracer.addSampler(sampler);
+    conf = conf.withSampler(sampler);
 
 Review comment:
   @jojochuang - I have one more question. Say I  have already started my region server and in this case it is Jaegar tracing. But while I start I don want any real tracing to happen. For eg I need to have the NoopScopeManager. But now by default the Region Server will initiliaze with ThreadLocalScopeManager. 
   `private ScopeManager scopeManager = new ThreadLocalScopeManager();`
   The above is from JaegerTracer.Builder.
   Now if I really want a tracer but with the scope doing nothing - is it possible? Next say if I want to dynamically enable tracing and then disable it how is that possible. 
   The config file that you had pointed out to is mainly to define per service what is the sampling type I want. But that again is predefined and there is no changing it. My requirement is if the RS needs to run with minimum friction and only on demand do my trace and again go back to minimum friction is it possible?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [hbase] ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)

Posted by GitBox <gi...@apache.org>.
ramkrish86 commented on a change in pull request #1210: HBASE-23757. [OpenTracing] Migrate from HTrace to OpenTracing (Java code)
URL: https://github.com/apache/hbase/pull/1210#discussion_r385262996
 
 

 ##########
 File path: hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java
 ##########
 @@ -17,103 +17,169 @@
  */
 package org.apache.hadoop.hbase.trace;
 
+import io.opentracing.Scope;
+import io.opentracing.SpanContext;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.Span;
+import io.opentracing.SpanContext;
+import io.opentracing.Tracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.propagation.TextMapInjectAdapter;
+import io.opentracing.util.GlobalTracer;
+import org.apache.commons.codec.binary.Hex;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.htrace.core.HTraceConfiguration;
 import org.apache.htrace.core.Sampler;
-import org.apache.htrace.core.Span;
 import org.apache.htrace.core.SpanReceiver;
 import org.apache.htrace.core.TraceScope;
-import org.apache.htrace.core.Tracer;
+import io.jaegertracing.Configuration.SamplerConfiguration;
+
+import org.apache.hadoop.tracing.TraceUtils;
+import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This wrapper class provides functions for accessing htrace 4+ functionality in a simplified way.
  */
 @InterfaceAudience.Private
 public final class TraceUtil {
-  private static HTraceConfiguration conf;
-  private static Tracer tracer;
+  static final Logger LOG = LoggerFactory.getLogger(TraceUtils.class);
+
+  private static io.jaegertracing.Configuration conf;
+  private static io.opentracing.Tracer tracer;
+
+  public static final String HBASE_OPENTRACING_TRACER = "hbase.opentracing.tracer";
+  public static final String HBASE_OPENTRACING_TRACER_DEFAULT = "jaeger";
+  public static final String HBASE_OPENTRACING_MOCKTRACER = "mock";
 
   private TraceUtil() {
   }
 
-  public static void initTracer(Configuration c) {
-    if (c != null) {
-      conf = new HBaseHTraceConfiguration(c);
+  public static void initTracer(Configuration c, String serviceName) {
+    if (GlobalTracer.isRegistered()) {
+      LOG.info("A tracer is already registered.");
+      return;
     }
 
-    if (tracer == null && conf != null) {
-      tracer = new Tracer.Builder("Tracer").conf(conf).build();
+    switch(c.get(HBASE_OPENTRACING_TRACER, HBASE_OPENTRACING_TRACER_DEFAULT)) {
+    case HBASE_OPENTRACING_TRACER_DEFAULT:
+      io.jaegertracing.Configuration conf = io.jaegertracing.Configuration.fromEnv(serviceName);
+      tracer = conf.getTracerBuilder().build();
+      break;
+    case HBASE_OPENTRACING_MOCKTRACER:
+      tracer = new MockTracer();
+      break;
+    default:
+      throw new RuntimeException("Unexpected tracer");
     }
+
+
+    GlobalTracer.register(tracer);
+
+  }
+
+  /*@VisibleForTesting
+  public static void registerTracerForTest(Tracer tracer) {
+    TraceUtil.tracer = tracer;
+    GlobalTracer.register(tracer);
+  }*/
+
+  public static Tracer getTracer() {
+    return tracer;
   }
 
   /**
-   * Wrapper method to create new TraceScope with the given description
-   * @return TraceScope or null when not tracing
+   * Wrapper method to create new Scope with the given description
+   * @return Scope or null when not tracing
    */
-  public static TraceScope createTrace(String description) {
-    return (tracer == null) ? null : tracer.newScope(description);
+  public static Scope createTrace(String description) {
+    return (tracer == null) ? null :
+        tracer.buildSpan(description).startActive(true);
   }
 
   /**
-   * Wrapper method to create new child TraceScope with the given description
+   * Wrapper method to create new child Scope with the given description
    * and parent scope's spanId
    * @param span parent span
-   * @return TraceScope or null when not tracing
+   * @return Scope or null when not tracing
    */
-  public static TraceScope createTrace(String description, Span span) {
-    if (span == null) {
-      return createTrace(description);
-    }
+  public static Scope createTrace(String description, Span span) {
+    if(span == null) return createTrace(description);
+
+    return (tracer == null) ? null : tracer.buildSpan(description).
+        asChildOf(span).startActive(true);
+  }
+
+  public static Scope createTrace(String description, SpanContext spanContext) {
+    if(spanContext == null) return createTrace(description);
 
-    return (tracer == null) ? null : tracer.newScope(description, span.getSpanId());
+    return (tracer == null) ? null : tracer.buildSpan(description).
+        asChildOf(spanContext).startActive(true);
   }
 
   /**
    * Wrapper method to add new sampler to the default tracer
    * @return true if added, false if it was already added
    */
-  public static boolean addSampler(Sampler sampler) {
+  public static boolean addSampler(SamplerConfiguration sampler) {
     if (sampler == null) {
       return false;
     }
 
-    return (tracer == null) ? false : tracer.addSampler(sampler);
+    conf = conf.withSampler(sampler);
 
 Review comment:
   I think this is getting called from clients which needs the tracing. This 'conf' may be null I believe when this is called. @jojochuang - thanks for pointing to me to the docs. I was trying do some similar stuff and I took your patch as a reference. Now there are some quesitons - Assume I have kept my RegionServer to work with No sampling (just assume I don trace the flushes/compactions). Now if the client side I have enabled some sampling(tracing) say for eg writes -  if the writes are propogated to the server and we do the tracing - in that case will the sampling applied as what the client has decided ? 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services