-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Add support for HBase versions 2.0.0 to 2.5.0. #18253
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
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
750e307
feat: Add support for HBase versions 2.0.0 to 2.5.0.
YaoYingLong 6772032
Merge branch 'main' into feature/hbase-2.0.0
YaoYingLong 85e0cff
feat: Code review issue optimization and repeated test code merging.
YaoYingLong 074d553
Merge branch 'main' into feature/hbase-2.0.0
YaoYingLong df40828
Merge branch 'main' into feature/hbase-2.0.0
trask 4101651
fix: Fix the bug causing the failed check
YaoYingLong bf11f65
Fix: spotlessJavaCheck execution failure
YaoYingLong dcd7d0b
Fix: Fix the issue where VirtualField has an overly broad scope.
YaoYingLong 9b3fd85
feat: Optimize code review issues
YaoYingLong 334e01c
Merge branch 'main' into feature/hbase-2.0.0
YaoYingLong bfba82a
fix: Fix fossa‑configuration‑check failure
YaoYingLong 1c9ef26
Merge remote-tracking branch 'origin/feature/hbase-2.0.0' into featur…
YaoYingLong 79d54f2
fix: remove :instrumentation:hbase:hbase-common:javaagent from .fossa…
YaoYingLong 0408afc
feat: Optimize code comments
YaoYingLong d07b69b
fix: document HBase latest dep test override
YaoYingLong e66dbf4
Merge branch 'main' into feature/hbase-2.0.0
laurit 09ace1f
review
laurit 4500547
Move shaded client tests into a suite
laurit 9ca8321
feat: Optimize test cases
YaoYingLong 9f4b364
fix: Resolve Spotless task execution failure
YaoYingLong e5948f7
review
laurit 4412291
flatten directory hierarchy
laurit 1d920c9
update fossa configuration
laurit df69aa0
Merge branch 'open-telemetry:main' into feature/hbase-2.0.0
YaoYingLong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
instrumentation/hbase/hbase-client-2.0.0/javaagent/build.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| plugins { | ||
| id("otel.javaagent-instrumentation") | ||
| } | ||
|
|
||
| otelJava { | ||
| // HBase 2.0.x test stack is not reliable on JDK 25+. | ||
| maxJavaVersionForTests.set(JavaVersion.VERSION_24) | ||
| } | ||
|
|
||
| muzzle { | ||
| pass { | ||
| group.set("org.apache.hbase") | ||
| module.set("hbase-client") | ||
| versions.set("[2.0.0, 2.5.0)") | ||
| assertInverse.set(true) | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(project(":instrumentation:hbase:hbase-common:javaagent")) | ||
|
|
||
| library("org.apache.hbase:hbase-client:2.0.0") | ||
| testLibrary("org.apache.hbase:hbase-client:2.3.7") | ||
| latestDepTestLibrary("org.apache.hbase:hbase-client:2.4.+") // documented limitation | ||
| testImplementation("com.google.code.findbugs:annotations:3.0.1") | ||
| testImplementation(project(":instrumentation:hbase:hbase-common:testing")) | ||
| } | ||
|
|
||
| tasks { | ||
| withType<Test>().configureEach { | ||
| usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) | ||
| systemProperty("collectMetadata", otelProps.collectMetadata) | ||
| jvmArgs( | ||
| "-Dotel.javaagent.exclude-classes=com.google.protobuf.*,com.fasterxml.jackson.*,com.google.common.*,ch.qos.logback.*,javax.xml.*", | ||
| ) | ||
| } | ||
|
|
||
| val testStableSemconv by registering(Test::class) { | ||
| // HBase test container binds fixed host ports, so do not run it alongside the default test task. | ||
| mustRunAfter(named("test")) | ||
|
|
||
| testClassesDirs = sourceSets.test.get().output.classesDirs | ||
| classpath = sourceSets.test.get().runtimeClasspath | ||
|
|
||
| jvmArgs( | ||
| "-Dotel.semconv-stability.opt-in=database", | ||
| "-Dotel.javaagent.exclude-classes=com.google.protobuf.*,com.fasterxml.jackson.*,com.google.common.*,ch.qos.logback.*,javax.xml.*", | ||
| ) | ||
| systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") | ||
| systemProperty("collectMetadata", otelProps.collectMetadata) | ||
| } | ||
|
|
||
| check { | ||
| dependsOn(testStableSemconv) | ||
| } | ||
|
|
||
| if (otelProps.denyUnsafe) { | ||
| withType<Test>().configureEach { | ||
| enabled = false | ||
| } | ||
| } | ||
| } | ||
134 changes: 134 additions & 0 deletions
134
...metry/javaagent/instrumentation/hbase/client/v2_0_0/AbstractRpcClientInstrumentation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.hbase.client.v2_0_0; | ||
|
laurit marked this conversation as resolved.
Outdated
|
||
|
|
||
| import static io.opentelemetry.javaagent.instrumentation.hbase.client.v2_0_0.HbaseSingletons.RC_THREAD_LOCAL; | ||
| import static io.opentelemetry.javaagent.instrumentation.hbase.client.v2_0_0.HbaseSingletons.TABLE_THREAD_LOCAL; | ||
| import static io.opentelemetry.javaagent.instrumentation.hbase.client.v2_0_0.HbaseSingletons.instrumenter; | ||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||
| import static net.bytebuddy.matcher.ElementMatchers.takesArgument; | ||
|
|
||
| import io.opentelemetry.context.Context; | ||
| import io.opentelemetry.context.Scope; | ||
| import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||
| import io.opentelemetry.javaagent.instrumentation.hbase.common.CallMethodHelper; | ||
| import io.opentelemetry.javaagent.instrumentation.hbase.common.HbaseRequest; | ||
| import io.opentelemetry.javaagent.instrumentation.hbase.common.RequestAndContext; | ||
| import java.net.InetSocketAddress; | ||
| import javax.annotation.Nullable; | ||
| import net.bytebuddy.asm.Advice; | ||
| import net.bytebuddy.description.type.TypeDescription; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
| import org.apache.hadoop.hbase.net.Address; | ||
| import org.apache.hadoop.hbase.security.User; | ||
| import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors; | ||
|
|
||
| public final class AbstractRpcClientInstrumentation implements TypeInstrumentation { | ||
|
laurit marked this conversation as resolved.
Outdated
|
||
|
|
||
| @Override | ||
| public ElementMatcher<TypeDescription> typeMatcher() { | ||
| return named("org.apache.hadoop.hbase.ipc.AbstractRpcClient"); | ||
| } | ||
|
|
||
| @Override | ||
| public void transform(TypeTransformer transformer) { | ||
| transformer.applyAdviceToMethod( | ||
| named("callMethod") | ||
| .and( | ||
| takesArgument( | ||
| 0, | ||
| named( | ||
| "org.apache.hbase.thirdparty.com.google.protobuf.Descriptors$MethodDescriptor"))) | ||
| .and(takesArgument(4, named("org.apache.hadoop.hbase.security.User"))) | ||
| .and(takesArgument(5, named("java.net.InetSocketAddress"))), | ||
| AbstractRpcClientInstrumentation.class.getName() + "$CallMethodAdvice"); | ||
|
laurit marked this conversation as resolved.
Outdated
|
||
|
|
||
| // 2.4.18 version | ||
| transformer.applyAdviceToMethod( | ||
| named("callMethod") | ||
| .and( | ||
| takesArgument( | ||
| 0, | ||
| named( | ||
| "org.apache.hbase.thirdparty.com.google.protobuf.Descriptors$MethodDescriptor"))) | ||
| .and(takesArgument(4, named("org.apache.hadoop.hbase.security.User"))) | ||
| .and(takesArgument(5, named("org.apache.hadoop.hbase.net.Address"))), | ||
|
laurit marked this conversation as resolved.
Outdated
|
||
| AbstractRpcClientInstrumentation.class.getName() + "$CallMethodLastAdvice"); | ||
| } | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public static class CallMethodAdvice { | ||
| @Advice.OnMethodEnter(suppress = Throwable.class) | ||
| public static RequestAndContext onEnter( | ||
| @Advice.Argument(0) Descriptors.MethodDescriptor md, | ||
| @Advice.Argument(4) User ticket, | ||
| @Advice.Argument(5) InetSocketAddress addr) { | ||
| HbaseRequest request = | ||
| CallMethodHelper.buildRequest( | ||
| md.getName(), TABLE_THREAD_LOCAL.get(), ticket.getName(), addr); | ||
| Context parentContext = Java8BytecodeBridge.currentContext(); | ||
| if (!instrumenter().shouldStart(parentContext, request)) { | ||
| return null; | ||
| } | ||
| Context context = instrumenter().start(parentContext, request); | ||
| Scope scope = context.makeCurrent(); | ||
| RequestAndContext requestAndContext = RequestAndContext.create(request, scope, context); | ||
| RC_THREAD_LOCAL.set(requestAndContext); | ||
| return requestAndContext; | ||
| } | ||
|
|
||
| @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||
| public static void onExit( | ||
| @Advice.Thrown Throwable throwable, | ||
| @Advice.Enter @Nullable RequestAndContext requestAndContext) { | ||
| if (requestAndContext == null) { | ||
| return; | ||
| } | ||
| RC_THREAD_LOCAL.remove(); | ||
| CallMethodHelper.handleOnExit(throwable, requestAndContext, instrumenter(), false); | ||
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public static class CallMethodLastAdvice { | ||
| @Advice.OnMethodEnter(suppress = Throwable.class) | ||
| public static RequestAndContext onEnter( | ||
| @Advice.Argument(0) Descriptors.MethodDescriptor md, | ||
| @Advice.Argument(4) User ticket, | ||
| @Advice.Argument(5) Address addr) { | ||
| HbaseRequest request = | ||
| CallMethodHelper.buildRequest( | ||
| md.getName(), | ||
| TABLE_THREAD_LOCAL.get(), | ||
| ticket.getName(), | ||
| addr.getHostname(), | ||
| addr.getPort()); | ||
| Context parentContext = Java8BytecodeBridge.currentContext(); | ||
| if (!instrumenter().shouldStart(parentContext, request)) { | ||
| return null; | ||
| } | ||
| Context context = instrumenter().start(parentContext, request); | ||
| Scope scope = context.makeCurrent(); | ||
|
|
||
| RequestAndContext requestAndContext = RequestAndContext.create(request, scope, context); | ||
| RC_THREAD_LOCAL.set(requestAndContext); | ||
| return requestAndContext; | ||
| } | ||
|
|
||
| @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||
| public static void onExit( | ||
| @Advice.Thrown Throwable throwable, | ||
| @Advice.Enter @Nullable RequestAndContext requestAndContext) { | ||
| if (requestAndContext == null) { | ||
| return; | ||
| } | ||
| RC_THREAD_LOCAL.remove(); | ||
| CallMethodHelper.handleOnExit(throwable, requestAndContext, instrumenter(), false); | ||
| } | ||
| } | ||
| } | ||
60 changes: 60 additions & 0 deletions
60
...entelemetry/javaagent/instrumentation/hbase/client/v2_0_0/HbaseInstrumentationModule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.hbase.client.v2_0_0; | ||
|
|
||
| import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; | ||
| import static java.util.Arrays.asList; | ||
| import static java.util.Collections.singletonList; | ||
| import static net.bytebuddy.matcher.ElementMatchers.not; | ||
|
|
||
| import com.google.auto.service.AutoService; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule; | ||
| import java.util.List; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
|
|
||
| @AutoService(InstrumentationModule.class) | ||
| public final class HbaseInstrumentationModule extends InstrumentationModule | ||
| implements ExperimentalInstrumentationModule { | ||
|
|
||
| private static final String CALL_UTIL = "org.apache.hadoop.hbase.ipc.OpenTelemetryCallUtil"; | ||
|
|
||
| public HbaseInstrumentationModule() { | ||
| super("hbase-client", "hbase-client-2.0.0"); | ||
|
laurit marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| @Override | ||
| public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() { | ||
| return hasClassesNamed("org.apache.hadoop.hbase.ipc.RpcConnection") | ||
| .and(hasClassesNamed("org.apache.hadoop.hbase.client.AsyncAdmin")) | ||
|
laurit marked this conversation as resolved.
Outdated
|
||
| .and(not(hasClassesNamed("org.apache.hadoop.hbase.client.trace.IpcClientSpanBuilder"))); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isHelperClass(String className) { | ||
| return CALL_UTIL.equals(className); | ||
| } | ||
|
|
||
| @Override | ||
| public List<String> injectedClassNames() { | ||
| return singletonList(CALL_UTIL); | ||
| } | ||
|
|
||
| @Override | ||
| public List<String> getAdditionalHelperClassNames() { | ||
| return singletonList(CALL_UTIL); | ||
| } | ||
|
laurit marked this conversation as resolved.
Outdated
|
||
|
|
||
| @Override | ||
| public List<TypeInstrumentation> typeInstrumentations() { | ||
| return asList( | ||
| new RegionServerCallableInstrumentation(), | ||
| new AbstractRpcClientInstrumentation(), | ||
| new RpcConnectionInstrumentation(), | ||
| new IpcCallInstrumentation()); | ||
| } | ||
| } | ||
27 changes: 27 additions & 0 deletions
27
.../java/io/opentelemetry/javaagent/instrumentation/hbase/client/v2_0_0/HbaseSingletons.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.hbase.client.v2_0_0; | ||
|
|
||
| import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
| import io.opentelemetry.javaagent.instrumentation.hbase.common.HbaseInstrumenterFactory; | ||
| import io.opentelemetry.javaagent.instrumentation.hbase.common.HbaseRequest; | ||
| import io.opentelemetry.javaagent.instrumentation.hbase.common.RequestAndContext; | ||
|
|
||
| public class HbaseSingletons { | ||
|
|
||
| public static final ThreadLocal<String> TABLE_THREAD_LOCAL = new ThreadLocal<>(); | ||
| public static final ThreadLocal<RequestAndContext> RC_THREAD_LOCAL = new ThreadLocal<>(); | ||
|
|
||
| private static final String INSTRUMENTATION_NAME = "io.opentelemetry.hbase-client-2.0.0"; | ||
| private static final Instrumenter<HbaseRequest, Void> INSTRUMENTER = | ||
| HbaseInstrumenterFactory.instrumenter(INSTRUMENTATION_NAME); | ||
|
laurit marked this conversation as resolved.
Outdated
|
||
|
|
||
| public static Instrumenter<HbaseRequest, Void> instrumenter() { | ||
| return INSTRUMENTER; | ||
| } | ||
|
|
||
| private HbaseSingletons() {} | ||
| } | ||
55 changes: 55 additions & 0 deletions
55
...o/opentelemetry/javaagent/instrumentation/hbase/client/v2_0_0/IpcCallInstrumentation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.hbase.client.v2_0_0; | ||
|
|
||
| import static io.opentelemetry.javaagent.instrumentation.hbase.client.v2_0_0.HbaseSingletons.instrumenter; | ||
| import static net.bytebuddy.matcher.ElementMatchers.isMethod; | ||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||
|
|
||
| import io.opentelemetry.context.Context; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||
| import io.opentelemetry.javaagent.instrumentation.hbase.common.HbaseRequest; | ||
| import io.opentelemetry.javaagent.instrumentation.hbase.common.RequestAndContext; | ||
| import java.io.IOException; | ||
| import net.bytebuddy.asm.Advice; | ||
| import net.bytebuddy.description.type.TypeDescription; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
| import org.apache.hadoop.hbase.ipc.OpenTelemetryCallUtil; | ||
|
|
||
| public final class IpcCallInstrumentation implements TypeInstrumentation { | ||
|
|
||
| @Override | ||
| public ElementMatcher<TypeDescription> typeMatcher() { | ||
| return named("org.apache.hadoop.hbase.ipc.Call"); | ||
| } | ||
|
|
||
| @Override | ||
| public void transform(TypeTransformer transformer) { | ||
| transformer.applyAdviceToMethod( | ||
| isMethod().and(named("callComplete").or(named("setTimeout"))), | ||
|
laurit marked this conversation as resolved.
Outdated
|
||
| IpcCallInstrumentation.class.getName() + "$CallAdvice"); | ||
|
|
||
| } | ||
|
|
||
| public static class CallAdvice { | ||
| @Advice.OnMethodEnter(suppress = Throwable.class) | ||
| public static void onEnter( | ||
| @Advice.This Object call, @Advice.FieldValue(value = "error") IOException error) { | ||
|
|
||
| RequestAndContext requestAndContext = | ||
| OpenTelemetryCallUtil.getAndClearRequestAndContext(call); | ||
| if (requestAndContext == null) { | ||
| return; | ||
| } | ||
|
|
||
| Context context = requestAndContext.getContext(); | ||
| HbaseRequest request = requestAndContext.getRequest(); | ||
| if (context == null || request == null) { | ||
| return; | ||
| } | ||
| instrumenter().end(context, request, null, error); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.