feat: Add support for HBase versions 2.0.0 to 2.5.0.#18253
feat: Add support for HBase versions 2.0.0 to 2.5.0.#18253YaoYingLong wants to merge 15 commits into
Conversation
|
hi @YaoYingLong! I'm going to convert this PR to draft, once you get CI passing or have any questions for us, please mark it ready for review, thanks |
@trask CI checks completed. |
|
|
||
| @Test | ||
| @Order(1) | ||
| public void testCreateNameBase() { |
| @Advice.OnMethodEnter(suppress = Throwable.class) | ||
| public static void onEnter( | ||
| @Advice.This Object call, @Advice.FieldValue(value = "error") IOException error) { |
| Exception error = null; | ||
| boolean tableExists = false; | ||
| try { | ||
| Admin admin = connection.getAdmin(); |
| .waitingFor(Wait.forHealthcheck().withStartupTimeout(Duration.ofMinutes(2))) | ||
| .withCreateContainerCmdModifier(cmd -> cmd.withHostName(HOSTNAME)) | ||
| .waitingFor(Wait.forListeningPort()) | ||
| .waitingFor(Wait.forLogMessage(".*Master has completed initialization.*\\n", 1)); |
| transformer.applyAdviceToMethod( | ||
| isMethod().and(named("callComplete").or(named("setTimeout"))), | ||
| IpcCallInstrumentation.class.getName() + "$CallAdvice"); |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.hbase.client.v2_0_0; |
There was a problem hiding this comment.
usually we just use 2_0 instead of 2_0_0
| import org.apache.hadoop.hbase.security.User; | ||
| import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors; | ||
|
|
||
| public final class AbstractRpcClientInstrumentation implements TypeInstrumentation { |
| 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"))), |
There was a problem hiding this comment.
As far as I can tell the only difference between the 2 advice is this argument. Perhaps the advice could accept Object and choose the correct behavior based on instanceof? Could that reduce the amount of code neede?
| "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"); |
There was a problem hiding this comment.
nowadays we prefer getClass().getNam()
| private static final String CALL_UTIL = "org.apache.hadoop.hbase.ipc.OpenTelemetryCallUtil"; | ||
|
|
||
| public HbaseInstrumentationModule() { | ||
| super("hbase-client", "hbase-client-2.0.0"); |
There was a problem hiding this comment.
elsewhere we use 2.0 instead of 2.0.0
| return hasClassesNamed("org.apache.hadoop.hbase.ipc.RpcConnection") | ||
| .and(hasClassesNamed("org.apache.hadoop.hbase.client.AsyncAdmin")) |
There was a problem hiding this comment.
could replace with hasClassesNamed("firs", "second")
| @Override | ||
| public List<String> getAdditionalHelperClassNames() { | ||
| return singletonList(CALL_UTIL); | ||
| } |
|
|
||
| private static final String INSTRUMENTATION_NAME = "io.opentelemetry.hbase-client-2.0.0"; | ||
| private static final Instrumenter<HbaseRequest, Void> INSTRUMENTER = | ||
| HbaseInstrumenterFactory.instrumenter(INSTRUMENTATION_NAME); |
There was a problem hiding this comment.
we use separate factory classes to share code between agent and library instrumentations here you could just move the code to this class
There was a problem hiding this comment.
This is because we still maintain the 1.x versions, and we haven't submitted the PR (Pull Request) yet.
| @Override | ||
| public void transform(TypeTransformer transformer) { | ||
| transformer.applyAdviceToMethod( | ||
| isMethod().and(named("callComplete").or(named("setTimeout"))), |
There was a problem hiding this comment.
isMethod() isn't needed. Instead of or you could use namedOneOf
|
|
||
| @Override | ||
| public ElementMatcher<TypeDescription> typeMatcher() { | ||
| return extendsClass(named("org.apache.hadoop.hbase.ipc.RpcConnection")); |
There was a problem hiding this comment.
when there are matcher that match based on class hierarchy we usually also add
@Override
public ElementMatcher<ClassLoader> classLoaderOptimization() {
return hasClassesNamed("org.apache.hadoop.hbase.ipc.RpcConnection");
}| 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") |
There was a problem hiding this comment.
so instead of 2.0.0 this is tested with 2.3.7
| 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.*", |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.hbase.common; |
There was a problem hiding this comment.
why do you need a common module, can't you put these into the javaagent module?
There was a problem hiding this comment.
This is because we still maintain the 1.x versions, and we haven't submitted the PR (Pull Request) yet.
|
|
||
| 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 |
There was a problem hiding this comment.
I think it would help to mention that hbase 2.5 includes native otel instrumentation
Add support for HBase versions [2.0.0, 2.5.0)