-
Notifications
You must be signed in to change notification settings - Fork 909
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
Add a ClassAndMethod class to Instrumentation API #4619
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,3 +384,18 @@ dependencies { | |
testImplementation(project(":instrumentation:yarpc-1.0:javaagent")) | ||
} | ||
``` | ||
|
||
## Why we don't use ByteBuddy @Advice.Origin Method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT about moving it to the |
||
|
||
Instead of | ||
``` | ||
@Advice.Origin Method method | ||
``` | ||
we prefer to use | ||
``` | ||
@Advice.Origin("#t") Class<?> declaringClass, | ||
@Advice.Origin("#m") String methodName | ||
``` | ||
because the former inserts a call to `Class.getMethod(...)` in transformed class. In contrast, | ||
laurit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
getting the declaring class and method name is just loading constants from constant pool, which is | ||
a much simpler operation. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,12 +115,17 @@ public static class WithSpanAdvice { | |
|
||
@Advice.OnMethodEnter(suppress = Throwable.class) | ||
public static void onEnter( | ||
@Advice.Origin Method method, | ||
@Advice.Origin Method originMethod, | ||
@Advice.Local("otelMethod") Method method, | ||
@Advice.Local("otelOperationEndSupport") | ||
AsyncOperationEndSupport<Method, Object> operationEndSupport, | ||
@Advice.Local("otelContext") Context context, | ||
@Advice.Local("otelScope") Scope scope) { | ||
|
||
// Every usage of @Advice.Origin Method is replaced with a call to Class.getMethod, copy it | ||
// to local variable so that there would be only one call to Class.getMethod. | ||
method = originMethod; | ||
|
||
Instrumenter<Method, Object> instrumenter = instrumenter(); | ||
Context current = Java8BytecodeBridge.currentContext(); | ||
|
||
|
@@ -134,7 +139,7 @@ public static void onEnter( | |
|
||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||
public static void stopSpan( | ||
@Advice.Origin Method method, | ||
@Advice.Local("otelMethod") Method method, | ||
@Advice.Local("otelOperationEndSupport") | ||
AsyncOperationEndSupport<Method, Object> operationEndSupport, | ||
@Advice.Local("otelContext") Context context, | ||
|
@@ -154,14 +159,19 @@ public static class WithSpanAttributesAdvice { | |
|
||
@Advice.OnMethodEnter(suppress = Throwable.class) | ||
public static void onEnter( | ||
@Advice.Origin Method method, | ||
@Advice.Origin Method originMethod, | ||
@Advice.Local("otelMethod") Method method, | ||
@Advice.AllArguments(typing = Assigner.Typing.DYNAMIC) Object[] args, | ||
@Advice.Local("otelOperationEndSupport") | ||
AsyncOperationEndSupport<MethodRequest, Object> operationEndSupport, | ||
@Advice.Local("otelRequest") MethodRequest request, | ||
@Advice.Local("otelContext") Context context, | ||
@Advice.Local("otelScope") Scope scope) { | ||
|
||
// Every usage of @Advice.Origin Method is replaced with a call to Class.getMethod, copy it | ||
// to local variable so that there would be only one call to Class.getMethod. | ||
method = originMethod; | ||
Comment on lines
+171
to
+173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh interesting, great find |
||
|
||
Instrumenter<MethodRequest, Object> instrumenter = instrumenterWithAttributes(); | ||
Context current = Java8BytecodeBridge.currentContext(); | ||
request = new MethodRequest(method, args); | ||
|
@@ -176,7 +186,7 @@ public static void onEnter( | |
|
||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||
public static void stopSpan( | ||
@Advice.Origin Method method, | ||
@Advice.Local("otelMethod") Method method, | ||
@Advice.Local("otelOperationEndSupport") | ||
AsyncOperationEndSupport<MethodRequest, Object> operationEndSupport, | ||
@Advice.Local("otelRequest") MethodRequest request, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍