Skip to content

HBASE-25853 Backport HBASE-22120 "Replace HTrace with OpenTelemetry" to branch-2 #3637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fc1aa5c
HBASE-26124 Backport HBASE-25373 "Remove HTrace completely in code ba…
taklwu Jul 29, 2021
1beffa7
HBASE-26125 Backport HBASE-25401 "Add trace support for async call in…
taklwu Aug 2, 2021
350288e
HBASE-26126 Backport HBASE-25424 "Find a way to config OpenTelemetry …
taklwu Aug 3, 2021
c96d8fd
HBASE-26127 Backport HBASE-23898 "Add trace support for simple apis i…
taklwu Aug 5, 2021
c3d577a
HBASE-26128 Backport HBASE-25454 "Add trace support for connection re…
taklwu Aug 12, 2021
e19784c
HBASE-26129 Backport HBASE-25481 "Add host and port attribute when tr…
taklwu Aug 17, 2021
811f089
HBASE-26130 Backport HBASE-25455 "Add trace support for HRegion read/…
taklwu Aug 18, 2021
aa0464c
HBASE-26131 Backport HBASE-25484 "Add trace support for WAL sync" to …
taklwu Aug 19, 2021
2e2cd4c
HBASE-26132 Backport HBASE-25535 "Set span kind to CLIENT in Abstract…
taklwu Aug 20, 2021
c479baa
HBASE-26133 Backport HBASE-25591 "Upgrade opentelemetry to 0.17.1" to…
taklwu Aug 23, 2021
554285e
HBASE-26134 Backport HBASE-25617 "Revisit the span names" to branch-2…
taklwu Aug 24, 2021
55e06a6
HBASE-26135 Backport HBASE-25616 "Upgrade opentelemetry to 1.0.0" to …
taklwu Aug 24, 2021
d14ab3e
HBASE-26136 Backport HBASE-25723 "Temporarily remove the trace suppor…
taklwu Aug 25, 2021
85e9c1a
HBASE-26137 Backport HBASE-25732 "Change the command line argument fo…
taklwu Aug 25, 2021
f925d32
HBASE-26138 Backport HBASE-25733 "Upgrade opentelemetry to 1.0.1" to …
taklwu Aug 26, 2021
2c0664e
HBASE-26139 Backport HBASE-23762 "Add documentation on how to enable …
taklwu Aug 26, 2021
275de8d
HBASE-26140 Backport HBASE-25778 "The tracinig implementation for Asy…
taklwu Aug 26, 2021
791fd64
HBASE-26168 Backport HBASE-25811 "The client integration test is fail…
taklwu Aug 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bin/hbase
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,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"
}

#Add the development env class path stuff
if $in_dev_env; then
add_maven_deps_to_classpath "cached_classpath.txt"
Expand Down Expand Up @@ -764,6 +769,11 @@ elif [ "${DEBUG}" = "true" ]; then
echo "JDK11 jars skipped from classpath."
fi

if [[ -n "${HBASE_TRACE_OPTS}" ]]; then
echo "Attach opentelemetry agent to enable trace"
enable_trace
fi

# Have JVM dump heap if we run out of memory. Files will be 'launch directory'
# and are named like the following: java_pid21612.hprof. Apparently it doesn't
# 'cost' to have this flag enabled. Its a 1.6 flag only. See:
Expand Down
5 changes: 5 additions & 0 deletions conf/hbase-env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ set HBASE_OPTS=%HBASE_OPTS% "-XX:+UseConcMarkSweepGC" "-Djava.net.preferIPv4Stac

@rem Tell HBase whether it should manage it's own instance of ZooKeeper or not.
@rem set HBASE_MANAGES_ZK=true

@rem Uncomment to enable trace, you can change the options to use other exporters such as jaeger or
@rem zipkin. See https://github.com/open-telemetry/opentelemetry-java-instrumentation on how to
@rem configure exporters and other components through system properties.
@rem set HBASE_TRACE_OPTS="-Dotel.resource.attributes=service.name=HBase -Dotel.traces.exporter=logging otel.metrics.exporter=none"
5 changes: 5 additions & 0 deletions conf/hbase-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,8 @@

# Additional argments passed to jshell invocation
# export HBASE_JSHELL_ARGS="--startup DEFAULT --startup PRINTING --startup hbase_startup.jsh"

# Uncomment to enable trace, you can change the options to use other exporters such as jaeger or
# zipkin. See https://github.com/open-telemetry/opentelemetry-java-instrumentation on how to
# configure exporters and other components through system properties.
# export HBASE_TRACE_OPTS="-Dotel.resource.attributes=service.name=HBase -Dotel.traces.exporter=logging otel.metrics.exporter=none"
6 changes: 6 additions & 0 deletions hbase-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<!-- Include OpenTelemetry agent -->
<dependency>
<groupId>io.opentelemetry.javaagent</groupId>
<artifactId>opentelemetry-javaagent</artifactId>
<classifier>all</classifier>
</dependency>
</dependencies>
<profiles>
<profile>
Expand Down
8 changes: 8 additions & 0 deletions hbase-assembly/src/main/assembly/client.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<exclude>org.slf4j:jcl-over-slf4j</exclude>
<exclude>org.slf4j:jul-to-slf4j</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
<exclude>io.opentelemetry.javaagent:*</exclude>
</excludes>
</dependencySet>
</dependencySets>
Expand Down Expand Up @@ -153,6 +154,13 @@
<include>org.slf4j:jcl-over-slf4j</include>
<include>org.slf4j:jul-to-slf4j</include>
<include>org.slf4j:slf4j-log4j12</include>
<include>io.opentelemetry:*</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>lib/trace</outputDirectory>
<includes>
<include>io.opentelemetry.javaagent:*</include>
</includes>
</dependencySet>
</dependencySets>
Expand Down
8 changes: 8 additions & 0 deletions hbase-assembly/src/main/assembly/hadoop-three-compat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<exclude>org.apache.yetus:audience-annotations</exclude>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
<exclude>io.opentelemetry.javaagent:*</exclude>
</excludes>
</dependencySet>
</dependencySets>
Expand Down Expand Up @@ -212,6 +213,7 @@
<include>org.slf4j:jcl-over-slf4j</include>
<include>org.slf4j:jul-to-slf4j</include>
<include>org.slf4j:slf4j-log4j12</include>
<include>io.opentelemetry:*</include>
</includes>
</dependencySet>
<dependencySet>
Expand Down Expand Up @@ -256,6 +258,12 @@
<include>jakarta.jws:jakarta.jws-api</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>lib/trace</outputDirectory>
<includes>
<include>io.opentelemetry.javaagent:*</include>
</includes>
</dependencySet>
</dependencySets>

</assembly>
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
14 changes: 12 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 All @@ -156,6 +156,16 @@
<groupId>org.jruby.joni</groupId>
<artifactId>joni</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.apache.hadoop.hbase.client;

import static org.apache.hadoop.hbase.trace.TraceUtil.trace;
import static org.apache.hadoop.hbase.trace.TraceUtil.tracedFuture;
import static org.apache.hadoop.hbase.util.FutureUtils.addListener;

import com.google.errorprone.annotations.RestrictedApi;
Expand Down Expand Up @@ -237,38 +239,48 @@ private static RegionLocations transformMetaRegionLocations(GetMetaRegionLocatio

@Override
public CompletableFuture<RegionLocations> getMetaRegionLocations() {
return this
.<GetMetaRegionLocationsResponse> call((c, s, d) -> s.getMetaRegionLocations(c,
GetMetaRegionLocationsRequest.getDefaultInstance(), d), r -> r.getMetaLocationsCount() != 0,
return tracedFuture(
() -> this
.<GetMetaRegionLocationsResponse> call(
(c, s, d) -> s.getMetaRegionLocations(c,
GetMetaRegionLocationsRequest.getDefaultInstance(), d),
r -> r.getMetaLocationsCount() != 0,
"getMetaLocationsCount")
.thenApply(AbstractRpcBasedConnectionRegistry::transformMetaRegionLocations);
.thenApply(AbstractRpcBasedConnectionRegistry::transformMetaRegionLocations),
getClass().getSimpleName() + ".getMetaRegionLocations");
}

@Override
public CompletableFuture<String> getClusterId() {
return this
.<GetClusterIdResponse> call(
(c, s, d) -> s.getClusterId(c, GetClusterIdRequest.getDefaultInstance(), d),
GetClusterIdResponse::hasClusterId, "getClusterId()")
.thenApply(GetClusterIdResponse::getClusterId);
return tracedFuture(
() -> this
.<GetClusterIdResponse> call(
(c, s, d) -> s.getClusterId(c, GetClusterIdRequest.getDefaultInstance(), d),
GetClusterIdResponse::hasClusterId, "getClusterId()")
.thenApply(GetClusterIdResponse::getClusterId),
getClass().getSimpleName() + ".getClusterId");
}

@Override
public CompletableFuture<ServerName> getActiveMaster() {
return this
.<GetActiveMasterResponse> call(
(c, s, d) -> s.getActiveMaster(c, GetActiveMasterRequest.getDefaultInstance(), d),
GetActiveMasterResponse::hasServerName, "getActiveMaster()")
.thenApply(resp -> ProtobufUtil.toServerName(resp.getServerName()));
return tracedFuture(
() -> this
.<GetActiveMasterResponse>call(
(c, s, d) -> s.getActiveMaster(c, GetActiveMasterRequest.getDefaultInstance(), d),
GetActiveMasterResponse::hasServerName, "getActiveMaster()")
.thenApply(resp -> ProtobufUtil.toServerName(resp.getServerName())),
getClass().getSimpleName() + ".getActiveMaster");
}

@Override
public void close() {
if (registryEndpointRefresher != null) {
registryEndpointRefresher.stop();
}
if (rpcClient != null) {
rpcClient.close();
}
trace(() -> {
if (registryEndpointRefresher != null) {
registryEndpointRefresher.stop();
}
if (rpcClient != null) {
rpcClient.close();
}
}, getClass().getSimpleName() + ".close");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public interface AsyncConnection extends Closeable {
/**
* Retrieve an {@link AsyncTable} implementation for accessing a table.
* <p>
* The returned instance will use default configs. Use {@link #getTableBuilder(TableName)} if
* you want to customize some configs.
* The returned instance will use default configs. Use {@link #getTableBuilder(TableName)} if you
* want to customize some configs.
* <p>
* This method no longer checks table existence. An exception will be thrown if the table does not
* exist only when the first operation is attempted.
Expand Down
Loading