Skip to content

Commit

Permalink
HBASE-26124 Backport HBASE-25373 to branch-2
Browse files Browse the repository at this point in the history
1/17 commits of HBASE-22120

Porting HBASE-25373 Remove HTrace completely in code base and try to make use of OpenTelemetry
back to branch-2
  • Loading branch information
taklwu committed Jul 27, 2021
1 parent 20a4aae commit cd79f3c
Show file tree
Hide file tree
Showing 43 changed files with 360 additions and 888 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@

import java.io.File;
import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.trace.TraceUtil;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -104,7 +102,6 @@ protected static void startMiniDFSCluster(int servers) throws IOException {
org.apache.log4j.Logger.getLogger(org.apache.hadoop.metrics2.impl.MetricsSystemImpl.class)
.setLevel(org.apache.log4j.Level.ERROR);

TraceUtil.initTracer(conf);
CLUSTER = new MiniDFSCluster.Builder(conf).numDataNodes(servers).build();
CLUSTER.waitClusterUp();
}
Expand Down
4 changes: 2 additions & 2 deletions hbase-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.htrace</groupId>
<artifactId>htrace-core4</artifactId>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
<dependency>
<groupId>org.jruby.jcodings</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.hadoop.hbase.client;

import io.opentelemetry.api.trace.Tracer;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -49,7 +50,6 @@
import org.apache.hadoop.hbase.trace.TraceUtil;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.htrace.core.Tracer;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -572,13 +572,9 @@ private Collection<? extends Runnable> getNewMultiActionRunnable(ServerName serv
asyncProcess.incTaskCounters(multiAction.getRegions(), server);
SingleServerRequestRunnable runnable = createSingleServerRequest(
multiAction, numAttempt, server, callsInProgress);
Tracer tracer = Tracer.curThreadTracer();

if (tracer == null) {
return Collections.singletonList(runnable);
} else {
return Collections.singletonList(tracer.wrap(runnable, "AsyncProcess.sendMultiAction"));
}
// remove trace for runnable because HBASE-25373 and OpenTelemetry do not cover TraceRunnable
return Collections.singletonList(runnable);
}

// group the actions by the amount of delay
Expand All @@ -598,12 +594,10 @@ private Collection<? extends Runnable> getNewMultiActionRunnable(ServerName serv
List<Runnable> toReturn = new ArrayList<>(actions.size());
for (DelayingRunner runner : actions.values()) {
asyncProcess.incTaskCounters(runner.getActions().getRegions(), server);
String traceText = "AsyncProcess.sendMultiAction";
Runnable runnable = createSingleServerRequest(runner.getActions(), numAttempt, server, callsInProgress);
// use a delay runner only if we need to sleep for some time
if (runner.getSleepTime() > 0) {
runner.setRunner(runnable);
traceText = "AsyncProcess.clientBackoff.sendMultiAction";
runnable = runner;
if (asyncProcess.connection.getConnectionMetrics() != null) {
asyncProcess.connection.getConnectionMetrics()
Expand All @@ -614,14 +608,14 @@ private Collection<? extends Runnable> getNewMultiActionRunnable(ServerName serv
asyncProcess.connection.getConnectionMetrics().incrNormalRunners();
}
}
runnable = TraceUtil.wrap(runnable, traceText);
// remove trace for runnable because HBASE-25373 and OpenTelemetry do not cover TraceRunnable
toReturn.add(runnable);

}
return toReturn;
}

/**
/**HBASE-25373
* @param server server location where the target region is hosted
* @param regionName name of the region which we are going to write some data
* @return the amount of time the client should wait until it submit a request to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public ResultBoundedCompletionService(

public void submit(RetryingCallable<V> task, int callTimeout, int id) {
QueueingFuture<V> newFuture = new QueueingFuture<>(task, callTimeout, id);
executor.execute(TraceUtil.wrap(newFuture, "ResultBoundedCompletionService.submit"));
// remove trace for runnable because HBASE-25373 and OpenTelemetry do not cover TraceRunnable
executor.execute(newFuture);
tasks[id] = newFuture;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import static org.apache.hadoop.hbase.ipc.IPCUtil.setCancelled;
import static org.apache.hadoop.hbase.ipc.IPCUtil.write;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
Expand Down Expand Up @@ -62,7 +65,6 @@
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.StringUtils;
import org.apache.htrace.core.TraceScope;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -593,9 +595,12 @@ private void negotiateCryptoAes(RPCProtos.CryptoCipherMeta cryptoCipherMeta)
}

private void tracedWriteRequest(Call call) throws IOException {
try (TraceScope ignored = TraceUtil.createTrace("RpcClientImpl.tracedWriteRequest",
call.span)) {
Span span = TraceUtil.getGlobalTracer().spanBuilder("RpcClientImpl.tracedWriteRequest")
.setParent(Context.current().with(call.span)).startSpan();
try (Scope scope = span.makeCurrent()) {
writeRequest(call);
} finally {
span.end();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@
*/
package org.apache.hadoop.hbase.ipc;

import io.opentelemetry.api.trace.Span;
import java.io.IOException;
import java.util.Optional;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.client.MetricsConnection;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.htrace.core.Span;
import org.apache.htrace.core.Tracer;
import org.apache.yetus.audience.InterfaceAudience;

import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors;
import org.apache.hbase.thirdparty.com.google.protobuf.Message;
import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback;
import org.apache.hbase.thirdparty.io.netty.util.Timeout;

import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;

/** A call waiting for a value. */
Expand Down Expand Up @@ -73,7 +74,7 @@ protected Call(int id, final Descriptors.MethodDescriptor md, Message param,
this.timeout = timeout;
this.priority = priority;
this.callback = callback;
this.span = Tracer.getCurrentSpan();
this.span = Span.current();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions hbase-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@
</dependency>
<!-- tracing Dependencies -->
<dependency>
<groupId>org.apache.htrace</groupId>
<artifactId>htrace-core4</artifactId>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit cd79f3c

Please sign in to comment.