1414import static net .bytebuddy .matcher .ElementMatchers .named ;
1515import static net .bytebuddy .matcher .ElementMatchers .not ;
1616import static net .bytebuddy .matcher .ElementMatchers .takesArgument ;
17+ import static net .bytebuddy .matcher .ElementMatchers .takesArguments ;
1718
1819import io .opentelemetry .instrumentation .thrift .v0_13 .internal .AsyncMethodCallbackUtil ;
1920import io .opentelemetry .instrumentation .thrift .v0_13 .internal .ClientCallContext ;
2930import org .apache .thrift .async .AsyncMethodCallback ;
3031import org .apache .thrift .async .TAsyncClient ;
3132import org .apache .thrift .protocol .TProtocolFactory ;
32- import org .apache .thrift .transport .TNonblockingTransport ;
3333
3434class 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