-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
162 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
...ain/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MapperMethodRequest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...ava/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisSpanNameExtractor.java
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
...va/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandInstrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; | ||
|
||
import static net.bytebuddy.matcher.ElementMatchers.isConstructor; | ||
import static net.bytebuddy.matcher.ElementMatchers.named; | ||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument; | ||
|
||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||
import java.lang.reflect.Method; | ||
import net.bytebuddy.asm.Advice; | ||
import net.bytebuddy.description.type.TypeDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
import org.apache.ibatis.binding.MapperMethod.SqlCommand; | ||
|
||
public class SqlCommandInstrumentation implements TypeInstrumentation { | ||
@Override | ||
public ElementMatcher<TypeDescription> typeMatcher() { | ||
return named("org.apache.ibatis.binding.MapperMethod$SqlCommand"); | ||
} | ||
|
||
@Override | ||
public void transform(TypeTransformer transformer) { | ||
transformer.applyAdviceToMethod( | ||
isConstructor().and(takesArgument(1, Class.class)).and(takesArgument(2, Method.class)), | ||
SqlCommandInstrumentation.class.getName() + "$ConstructorAdvice"); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public static class ConstructorAdvice { | ||
|
||
@Advice.OnMethodExit(suppress = Throwable.class) | ||
public static void onExit( | ||
@Advice.This SqlCommand command, | ||
@Advice.Argument(1) Class<?> mapperInterface, | ||
@Advice.Argument(2) Method method) { | ||
SqlCommandUtil.setClassAndMethod(command, mapperInterface, method); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; | ||
|
||
import io.opentelemetry.instrumentation.api.incubator.semconv.util.ClassAndMethod; | ||
import io.opentelemetry.instrumentation.api.util.VirtualField; | ||
import java.lang.reflect.Method; | ||
import org.apache.ibatis.binding.MapperMethod.SqlCommand; | ||
|
||
public final class SqlCommandUtil { | ||
private static final VirtualField<SqlCommand, ClassAndMethod> field = | ||
VirtualField.find(SqlCommand.class, ClassAndMethod.class); | ||
|
||
public static void setClassAndMethod(SqlCommand command, Class<?> clazz, Method method) { | ||
if (clazz == null || method == null || method.getName() == null) { | ||
return; | ||
} | ||
field.set(command, ClassAndMethod.create(clazz, method.getName())); | ||
} | ||
|
||
public static ClassAndMethod getClassAndMethod(SqlCommand command) { | ||
return field.get(command); | ||
} | ||
|
||
private SqlCommandUtil() {} | ||
} |
Oops, something went wrong.