File tree Expand file tree Collapse file tree 6 files changed +30
-25
lines changed
instrumentation/opentelemetry-api/opentelemetry-api-1.0
javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi
testing/src/main/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi Expand file tree Collapse file tree 6 files changed +30
-25
lines changed Original file line number Diff line number Diff line change 1515import io .opentelemetry .javaagent .extension .instrumentation .TypeTransformer ;
1616import io .opentelemetry .javaagent .instrumentation .opentelemetryapi .context .AgentContextStorage ;
1717import net .bytebuddy .asm .Advice ;
18+ import net .bytebuddy .asm .Advice .AssignReturned ;
1819import net .bytebuddy .description .type .TypeDescription ;
1920import net .bytebuddy .matcher .ElementMatcher ;
2021
@@ -41,9 +42,10 @@ public void transform(TypeTransformer transformer) {
4142 @ SuppressWarnings ("unused" )
4243 public static class WrapRootAdvice {
4344
45+ @ AssignReturned .ToReturned
4446 @ Advice .OnMethodExit (onThrowable = Throwable .class , suppress = Throwable .class )
45- public static void methodExit (@ Advice .Return ( readOnly = false ) Context root ) {
46- root = AgentContextStorage .wrapRootContext (root );
47+ public static Context methodExit (@ Advice .Return Context root ) {
48+ return AgentContextStorage .wrapRootContext (root );
4749 }
4850 }
4951}
Original file line number Diff line number Diff line change 1515import java .util .List ;
1616import java .util .function .Function ;
1717import net .bytebuddy .asm .Advice ;
18+ import net .bytebuddy .asm .Advice .AssignReturned ;
1819import net .bytebuddy .description .type .TypeDescription ;
1920import net .bytebuddy .matcher .ElementMatcher ;
2021
@@ -41,13 +42,16 @@ public void transform(TypeTransformer transformer) {
4142 @ SuppressWarnings ("unused" )
4243 public static class AddWrapperAdvice {
4344
45+ @ AssignReturned .ToReturned
4446 @ Advice .OnMethodExit (onThrowable = Throwable .class , suppress = Throwable .class )
45- public static void methodExit (
46- @ Advice .Return (readOnly = false )
47- List <Function <? super ContextStorage , ? extends ContextStorage >> wrappers ) {
47+ public static List <Function <? super ContextStorage , ? extends ContextStorage >> methodExit (
48+ @ Advice .Return
49+ List <Function <? super ContextStorage , ? extends ContextStorage >> originalWrappers ) {
50+ List <Function <? super ContextStorage , ? extends ContextStorage >> wrappers = originalWrappers ;
4851 wrappers = new ArrayList <>(wrappers );
4952 // AgentContextStorage wrapper doesn't delegate, so needs to be the innermost wrapper
5053 wrappers .add (0 , AgentContextStorage .wrap ());
54+ return wrappers ;
5155 }
5256 }
5357}
Original file line number Diff line number Diff line change 1515import io .opentelemetry .javaagent .extension .instrumentation .TypeTransformer ;
1616import io .opentelemetry .javaagent .instrumentation .opentelemetryapi .context .AgentContextStorage ;
1717import net .bytebuddy .asm .Advice ;
18+ import net .bytebuddy .asm .Advice .AssignReturned ;
1819import net .bytebuddy .description .type .TypeDescription ;
1920import net .bytebuddy .matcher .ElementMatcher ;
2021
@@ -44,12 +45,11 @@ public static boolean methodEnter() {
4445 return true ;
4546 }
4647
48+ @ AssignReturned .ToReturned
4749 @ Advice .OnMethodExit (suppress = Throwable .class )
48- public static void methodExit (
49- @ Advice .Argument (0 ) Context context , @ Advice .Return (readOnly = false ) boolean result ) {
50- result =
51- InstrumentationUtil .shouldSuppressInstrumentation (
52- AgentContextStorage .getAgentContext (context ));
50+ public static boolean methodExit (@ Advice .Argument (0 ) Context context ) {
51+ return InstrumentationUtil .shouldSuppressInstrumentation (
52+ AgentContextStorage .getAgentContext (context ));
5353 }
5454 }
5555
Original file line number Diff line number Diff line change 1717import io .opentelemetry .javaagent .extension .instrumentation .TypeTransformer ;
1818import java .util .logging .Logger ;
1919import net .bytebuddy .asm .Advice ;
20+ import net .bytebuddy .asm .Advice .AssignReturned ;
2021import net .bytebuddy .description .type .TypeDescription ;
2122import net .bytebuddy .matcher .ElementMatcher ;
2223
@@ -58,11 +59,10 @@ public static Object onEnter() {
5859 return null ;
5960 }
6061
62+ @ AssignReturned .ToReturned
6163 @ Advice .OnMethodExit (onThrowable = Throwable .class , suppress = Throwable .class )
62- public static void methodExit (
63- @ Advice .Return (readOnly = false )
64- application .io .opentelemetry .api .OpenTelemetry openTelemetry ) {
65- openTelemetry = ApplicationOpenTelemetry .INSTANCE ;
64+ public static application .io .opentelemetry .api .OpenTelemetry methodExit () {
65+ return ApplicationOpenTelemetry .INSTANCE ;
6666 }
6767 }
6868
Original file line number Diff line number Diff line change 1515import io .opentelemetry .javaagent .extension .instrumentation .TypeTransformer ;
1616import io .opentelemetry .javaagent .instrumentation .opentelemetryapi .trace .Bridging ;
1717import net .bytebuddy .asm .Advice ;
18+ import net .bytebuddy .asm .Advice .AssignReturned ;
1819import net .bytebuddy .description .type .TypeDescription ;
1920import net .bytebuddy .matcher .ElementMatcher ;
2021
@@ -40,13 +41,11 @@ public static boolean methodEnter() {
4041 return false ;
4142 }
4243
44+ @ AssignReturned .ToReturned
4345 @ Advice .OnMethodExit
44- public static void methodExit (
45- @ Advice .Argument (0 ) SpanContext applicationSpanContext ,
46- @ Advice .Return (readOnly = false ) Span applicationSpan ) {
47- applicationSpan =
48- Bridging .toApplication (
49- io .opentelemetry .api .trace .Span .wrap (Bridging .toAgent (applicationSpanContext )));
46+ public static Span methodExit (@ Advice .Argument (0 ) SpanContext applicationSpanContext ) {
47+ return Bridging .toApplication (
48+ io .opentelemetry .api .trace .Span .wrap (Bridging .toAgent (applicationSpanContext )));
5049 }
5150 }
5251}
Original file line number Diff line number Diff line change 1313import io .opentelemetry .javaagent .extension .instrumentation .TypeTransformer ;
1414import io .opentelemetry .javaagent .instrumentation .opentelemetryapi .context .AgentContextStorage ;
1515import net .bytebuddy .asm .Advice ;
16+ import net .bytebuddy .asm .Advice .AssignReturned ;
1617import net .bytebuddy .description .type .TypeDescription ;
1718import net .bytebuddy .matcher .ElementMatcher ;
1819
@@ -31,12 +32,11 @@ public void transform(TypeTransformer transformer) {
3132 @ SuppressWarnings ("unused" )
3233 public static class TestAdvice {
3334
35+ @ AssignReturned .ToReturned
3436 @ Advice .OnMethodExit (suppress = Throwable .class )
35- public static void onExit (
36- @ Advice .Argument (0 ) Context context , @ Advice .Return (readOnly = false ) boolean result ) {
37- result =
38- InstrumentationUtil .shouldSuppressInstrumentation (
39- AgentContextStorage .getAgentContext (context ));
37+ public static boolean onExit (@ Advice .Argument (0 ) Context context ) {
38+ return InstrumentationUtil .shouldSuppressInstrumentation (
39+ AgentContextStorage .getAgentContext (context ));
4040 }
4141 }
4242}
You can’t perform that action at this time.
0 commit comments