Skip to content

feat: Add support for HBase versions 2.0.0 to 2.5.0.#18253

Open
YaoYingLong wants to merge 15 commits into
open-telemetry:mainfrom
YaoYingLong:feature/hbase-2.0.0
Open

feat: Add support for HBase versions 2.0.0 to 2.5.0.#18253
YaoYingLong wants to merge 15 commits into
open-telemetry:mainfrom
YaoYingLong:feature/hbase-2.0.0

Conversation

@YaoYingLong
Copy link
Copy Markdown
Contributor

Add support for HBase versions [2.0.0, 2.5.0)

@YaoYingLong YaoYingLong requested a review from a team as a code owner April 24, 2026 03:43
@otelbot-java-instrumentation otelbot-java-instrumentation Bot added the test native This label can be applied to PRs to trigger them to run native tests label Apr 24, 2026
@trask
Copy link
Copy Markdown
Member

trask commented Apr 25, 2026

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 trask marked this pull request as draft April 25, 2026 20:58
@trask trask mentioned this pull request May 5, 2026
@YaoYingLong YaoYingLong marked this pull request as ready for review May 13, 2026 09:47
Copilot AI review requested due to automatic review settings May 13, 2026 09:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@YaoYingLong
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.


@Test
@Order(1)
public void testCreateNameBase() {
Comment on lines +38 to +40
@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();
Comment on lines +115 to +118
.waitingFor(Wait.forHealthcheck().withStartupTimeout(Duration.ofMinutes(2)))
.withCreateContainerCmdModifier(cmd -> cmd.withHostName(HOSTNAME))
.waitingFor(Wait.forListeningPort())
.waitingFor(Wait.forLogMessage(".*Master has completed initialization.*\\n", 1));
Comment on lines +32 to +34
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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be package private

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"))),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elsewhere we use 2.0 instead of 2.0.0

Comment on lines +32 to +33
return hasClassesNamed("org.apache.hadoop.hbase.ipc.RpcConnection")
.and(hasClassesNamed("org.apache.hadoop.hbase.client.AsyncAdmin"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could replace with hasClassesNamed("firs", "second")

Comment on lines +47 to +50
@Override
public List<String> getAdditionalHelperClassNames() {
return singletonList(CALL_UTIL);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed?


private static final String INSTRUMENTATION_NAME = "io.opentelemetry.hbase-client-2.0.0";
private static final Instrumenter<HbaseRequest, Void> INSTRUMENTER =
HbaseInstrumenterFactory.instrumenter(INSTRUMENTATION_NAME);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use separate factory classes to share code between agent and library instrumentations here you could just move the code to this class

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"))),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.*",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would you need this?

* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.hbase.common;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need a common module, can't you put these into the javaagent module?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would help to mention that hbase 2.5 includes native otel instrumentation

@YaoYingLong
Copy link
Copy Markdown
Contributor Author

@trask @laurit All issues found in the review have been fixed. Please review again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test native This label can be applied to PRs to trigger them to run native tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants