Skip to content

Commit fa3f3bc

Browse files
committed
Tighten TAsyncClient constructor matcher and drop unused transport binding
1 parent f4e6b67 commit fa3f3bc

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

instrumentation/thrift-0.13/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/thrift/v0_13/ThriftAsyncClientInstrumentation.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import static net.bytebuddy.matcher.ElementMatchers.named;
1515
import static net.bytebuddy.matcher.ElementMatchers.not;
1616
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
17+
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
1718

1819
import io.opentelemetry.instrumentation.thrift.v0_13.internal.AsyncMethodCallbackUtil;
1920
import io.opentelemetry.instrumentation.thrift.v0_13.internal.ClientCallContext;
@@ -29,7 +30,6 @@
2930
import org.apache.thrift.async.AsyncMethodCallback;
3031
import org.apache.thrift.async.TAsyncClient;
3132
import org.apache.thrift.protocol.TProtocolFactory;
32-
import org.apache.thrift.transport.TNonblockingTransport;
3333

3434
class ThriftAsyncClientInstrumentation implements TypeInstrumentation {
3535

@@ -47,7 +47,10 @@ public ElementMatcher<ClassLoader> classLoaderOptimization() {
4747
@Override
4848
public void transform(TypeTransformer transformer) {
4949
transformer.applyAdviceToMethod(
50-
isConstructor().and(takesArgument(0, named("org.apache.thrift.protocol.TProtocolFactory"))),
50+
isConstructor()
51+
.and(takesArguments(3))
52+
.and(takesArgument(0, named("org.apache.thrift.protocol.TProtocolFactory")))
53+
.and(takesArgument(2, named("org.apache.thrift.transport.TNonblockingTransport"))),
5154
getClass().getName() + "$ConstructorAdvice");
5255

5356
transformer.applyAdviceToMethod(
@@ -69,9 +72,7 @@ public void transform(TypeTransformer transformer) {
6972
public static class ConstructorAdvice {
7073
@Advice.AssignReturned.ToArguments(@ToArgument(0))
7174
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
72-
public static TProtocolFactory onEnter(
73-
@Advice.Argument(0) TProtocolFactory protocolFactory,
74-
@Advice.Argument(2) TNonblockingTransport transport) {
75+
public static TProtocolFactory onEnter(@Advice.Argument(0) TProtocolFactory protocolFactory) {
7576
return new ClientProtocolDecorator.Factory(protocolFactory, getPropagators());
7677
}
7778
}

0 commit comments

Comments
 (0)