From 8e2d39b071acf25c80714f476d84bdbd6541f006 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Thu, 8 Feb 2024 14:55:29 +0200 Subject: [PATCH] Rework mybatis instrumentation --- docs/supported-libraries.md | 3 +- .../mybatis-3.2/javaagent/build.gradle.kts | 7 +-- ....java => MapperMethodInstrumentation.java} | 25 ++++++---- .../mybatis/v3_2/MapperMethodRequest.java | 18 ------- .../v3_2/MyBatisInstrumentationModule.java | 10 +++- .../mybatis/v3_2/MyBatisSingletons.java | 26 ++++++---- .../v3_2/MyBatisSpanNameExtractor.java | 23 --------- .../v3_2/SqlCommandInstrumentation.java | 44 +++++++++++++++++ .../mybatis/v3_2/SqlCommandUtil.java | 29 ++++++++++++ .../mybatis/v3_2/MyBatisTest.java | 47 +++++++++++++------ .../mybatis/v3_2/RecordMapper.java | 14 ------ .../mybatis/v3_2/TestMapper.java | 14 ++++++ 12 files changed, 162 insertions(+), 98 deletions(-) rename instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/{MyBatisExecuteInstrumentation.java => MapperMethodInstrumentation.java} (70%) delete mode 100644 instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MapperMethodRequest.java delete mode 100644 instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisSpanNameExtractor.java create mode 100644 instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandInstrumentation.java create mode 100644 instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandUtil.java delete mode 100644 instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/RecordMapper.java create mode 100644 instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/TestMapper.java diff --git a/docs/supported-libraries.md b/docs/supported-libraries.md index c22694fd5eba..3d274eeea72c 100644 --- a/docs/supported-libraries.md +++ b/docs/supported-libraries.md @@ -94,7 +94,7 @@ These are the supported libraries and frameworks: | [Logback](http://logback.qos.ch/) | 1.0+ | [opentelemetry-logback-appender-1.0](../instrumentation/logback/logback-appender-1.0/library),
[opentelemetry-logback-mdc-1.0](../instrumentation/logback/logback-mdc-1.0/library) | none | | [Micrometer](https://micrometer.io/) | 1.5+ | [opentelemetry-micrometer-1.5](../instrumentation/micrometer/micrometer-1.5/library) | none | | [MongoDB Driver](https://mongodb.github.io/mongo-java-driver/) | 3.1+ | [opentelemetry-mongo-3.1](../instrumentation/mongo/mongo-3.1/library) | [Database Client Spans] | -| [MyBatis](https://mybatis.org/mybatis-3/) | 3.2.0+ | N/A | none | +| [MyBatis](https://mybatis.org/mybatis-3/) | 3.2+ | N/A | none | | [Netty](https://github.com/netty/netty) | 3.8+ | [opentelemetry-netty-4.1](../instrumentation/netty/netty-4.1/library) | [HTTP Client Spans], [HTTP Client Metrics], [HTTP Server Spans], [HTTP Server Metrics] | | [OkHttp](https://github.com/square/okhttp/) | 2.2+ | [opentelemetry-okhttp-3.0](../instrumentation/okhttp/okhttp-3.0/library) | [HTTP Client Spans], [HTTP Client Metrics] | | [Oracle UCP](https://docs.oracle.com/database/121/JJUCP/) | 11.2+ | [opentelemetry-oracle-ucp-11.2](../instrumentation/oracle-ucp-11.2/library) | [Database Pool Metrics] | @@ -145,7 +145,6 @@ These are the supported libraries and frameworks: | [Vert.x Web](https://vertx.io/docs/vertx-web/java/) | 3.0+ | N/A | Provides `http.route` [2] | | [Vibur DBCP](https://www.vibur.org/) | 11.0+ | [opentelemetry-vibur-dbcp-11.0](../instrumentation/vibur-dbcp-11.0/library) | [Database Pool Metrics] | | [ZIO](https://zio.dev/) | 2.0+ | N/A | Context propagation | -| [MyBatis](https://mybatis.org/mybatis-3/) | 3.2.0+ | N/A | none | **[1]** Standalone library instrumentation refers to instrumentation that can be used without the Java agent. diff --git a/instrumentation/mybatis-3.2/javaagent/build.gradle.kts b/instrumentation/mybatis-3.2/javaagent/build.gradle.kts index d0296fe756a1..c7c8a098ea77 100644 --- a/instrumentation/mybatis-3.2/javaagent/build.gradle.kts +++ b/instrumentation/mybatis-3.2/javaagent/build.gradle.kts @@ -12,17 +12,14 @@ muzzle { } dependencies { - compileOnly("com.google.auto.value:auto-value-annotations") - annotationProcessor("com.google.auto.value:auto-value") - library("org.mybatis:mybatis:3.2.0") - testImplementation("org.mockito:mockito-core") - testImplementation("org.mockito:mockito-junit-jupiter") testImplementation("com.h2database:h2:1.4.191") } tasks.withType().configureEach { + jvmArgs("-Dotel.instrumentation.mybatis.enabled=true") + // required on jdk17 jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") diff --git a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisExecuteInstrumentation.java b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MapperMethodInstrumentation.java similarity index 70% rename from instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisExecuteInstrumentation.java rename to instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MapperMethodInstrumentation.java index f6723e5b5e62..741005717f60 100644 --- a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisExecuteInstrumentation.java +++ b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MapperMethodInstrumentation.java @@ -6,11 +6,12 @@ package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; -import static io.opentelemetry.javaagent.instrumentation.mybatis.v3_2.MyBatisSingletons.mapperInstrumenter; +import static io.opentelemetry.javaagent.instrumentation.mybatis.v3_2.MyBatisSingletons.instrumenter; import static net.bytebuddy.matcher.ElementMatchers.named; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; +import io.opentelemetry.instrumentation.api.incubator.semconv.util.ClassAndMethod; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; import net.bytebuddy.asm.Advice; @@ -18,7 +19,7 @@ import net.bytebuddy.matcher.ElementMatcher; import org.apache.ibatis.binding.MapperMethod.SqlCommand; -public class MyBatisExecuteInstrumentation implements TypeInstrumentation { +public class MapperMethodInstrumentation implements TypeInstrumentation { @Override public ElementMatcher typeMatcher() { @@ -28,7 +29,7 @@ public ElementMatcher typeMatcher() { @Override public void transform(TypeTransformer transformer) { transformer.applyAdviceToMethod( - named("execute"), MyBatisExecuteInstrumentation.class.getName() + "$ExecuteAdvice"); + named("execute"), MapperMethodInstrumentation.class.getName() + "$ExecuteAdvice"); } @SuppressWarnings("unused") @@ -37,27 +38,33 @@ public static class ExecuteAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static void getMapperInfo( @Advice.FieldValue("command") SqlCommand command, - @Advice.Local("otelRequest") MapperMethodRequest request, + @Advice.Local("otelRequest") ClassAndMethod request, @Advice.Local("otelContext") Context context, @Advice.Local("otelScope") Scope scope) { + if (command == null) { + return; + } + request = SqlCommandUtil.getClassAndMethod(command); + if (request == null) { + return; + } Context parentContext = currentContext(); - if (command == null || !mapperInstrumenter().shouldStart(parentContext, request)) { + if (!instrumenter().shouldStart(parentContext, request)) { return; } - request = MapperMethodRequest.create(command.getName()); - context = mapperInstrumenter().start(parentContext, request); + context = instrumenter().start(parentContext, request); scope = context.makeCurrent(); } @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void stopSpan( @Advice.Thrown Throwable throwable, - @Advice.Local("otelRequest") MapperMethodRequest request, + @Advice.Local("otelRequest") ClassAndMethod request, @Advice.Local("otelContext") Context context, @Advice.Local("otelScope") Scope scope) { if (scope != null) { scope.close(); - mapperInstrumenter().end(context, request, null, throwable); + instrumenter().end(context, request, null, throwable); } } } diff --git a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MapperMethodRequest.java b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MapperMethodRequest.java deleted file mode 100644 index cd8be5b7d48f..000000000000 --- a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MapperMethodRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class MapperMethodRequest { - - public static MapperMethodRequest create(String mapperName) { - return new AutoValue_MapperMethodRequest(mapperName); - } - - public abstract String getMapperName(); -} diff --git a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisInstrumentationModule.java b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisInstrumentationModule.java index 9419d589bbe7..55d4910ef232 100644 --- a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisInstrumentationModule.java +++ b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisInstrumentationModule.java @@ -5,11 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; -import static java.util.Collections.singletonList; +import static java.util.Arrays.asList; import com.google.auto.service.AutoService; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import java.util.List; @AutoService(InstrumentationModule.class) @@ -21,6 +22,11 @@ public MyBatisInstrumentationModule() { @Override public List typeInstrumentations() { - return singletonList(new MyBatisExecuteInstrumentation()); + return asList(new MapperMethodInstrumentation(), new SqlCommandInstrumentation()); + } + + @Override + public boolean defaultEnabled(ConfigProperties config) { + return false; } } diff --git a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisSingletons.java b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisSingletons.java index 6145f8aa765f..b24eac8cce1e 100644 --- a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisSingletons.java +++ b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisSingletons.java @@ -6,26 +6,32 @@ package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor; +import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesGetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeSpanNameExtractor; +import io.opentelemetry.instrumentation.api.incubator.semconv.util.ClassAndMethod; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; public final class MyBatisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.mybatis-3.2"; - - private static final Instrumenter MAPPER_INSTRUMENTER; + private static final Instrumenter INSTRUMENTER; static { - SpanNameExtractor spanNameExtractor = new MyBatisSpanNameExtractor(); - - MAPPER_INSTRUMENTER = - Instrumenter.builder( - GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanNameExtractor) + CodeAttributesGetter codeAttributesGetter = + ClassAndMethod.codeAttributesGetter(); + + INSTRUMENTER = + Instrumenter.builder( + GlobalOpenTelemetry.get(), + INSTRUMENTATION_NAME, + CodeSpanNameExtractor.create(codeAttributesGetter)) + .addAttributesExtractor(CodeAttributesExtractor.create(codeAttributesGetter)) .buildInstrumenter(SpanKindExtractor.alwaysInternal()); } - public static Instrumenter mapperInstrumenter() { - return MAPPER_INSTRUMENTER; + public static Instrumenter instrumenter() { + return INSTRUMENTER; } private MyBatisSingletons() {} diff --git a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisSpanNameExtractor.java b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisSpanNameExtractor.java deleted file mode 100644 index b8e8b9371433..000000000000 --- a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisSpanNameExtractor.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; - -import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; - -public class MyBatisSpanNameExtractor implements SpanNameExtractor { - - @Override - public String extract(MapperMethodRequest request) { - String mapperName = request.getMapperName(); - if (mapperName == null) { - return "MyBatis execute"; - } - // filter the package name in mapperName - int lastDotIndex = mapperName.lastIndexOf('.'); - int secondLastDotIndex = mapperName.lastIndexOf('.', lastDotIndex - 1); - return mapperName.substring(secondLastDotIndex + 1); - } -} diff --git a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandInstrumentation.java b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandInstrumentation.java new file mode 100644 index 000000000000..c137bd294082 --- /dev/null +++ b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandInstrumentation.java @@ -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 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); + } + } +} diff --git a/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandUtil.java b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandUtil.java new file mode 100644 index 000000000000..f67692f47229 --- /dev/null +++ b/instrumentation/mybatis-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/SqlCommandUtil.java @@ -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 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() {} +} diff --git a/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisTest.java b/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisTest.java index 2ad0a191ab02..42b81e0b1ee0 100644 --- a/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisTest.java +++ b/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/MyBatisTest.java @@ -5,43 +5,60 @@ package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; + import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.semconv.SemanticAttributes; import org.apache.ibatis.mapping.Environment; import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; import org.h2.jdbcx.JdbcDataSource; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; class MyBatisTest { @RegisterExtension - protected static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); + private static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); - @Test - void mybatis() { + private static SqlSession sqlSession; + + @BeforeAll + static void setUp() { JdbcDataSource dataSource = new JdbcDataSource(); dataSource.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); Configuration configuration = new Configuration(); configuration.setEnvironment(new Environment("test", new JdbcTransactionFactory(), dataSource)); - configuration.addMapper(RecordMapper.class); - SqlSession sqlSession = new SqlSessionFactoryBuilder().build(configuration).openSession(); - RecordMapper recordMapper = sqlSession.getMapper(RecordMapper.class); - recordMapper.updateRecord(); - assertMyBatisTraces("RecordMapper.updateRecord"); + configuration.addMapper(TestMapper.class); + sqlSession = new SqlSessionFactoryBuilder().build(configuration).openSession(); } - private static void assertMyBatisTraces(String spanName) { + @AfterAll + static void cleanUp() { + if (sqlSession != null) { + sqlSession.close(); + } + } + + @Test + void testSelect() { + TestMapper testMapper = sqlSession.getMapper(TestMapper.class); + testMapper.select(); + testing.waitAndAssertTraces( - trace -> { - trace.hasSpansSatisfyingExactly( - span -> { - span.hasKind(SpanKind.INTERNAL).hasName(spanName); - }); - }); + trace -> + trace.hasSpansSatisfyingExactly( + span -> + span.hasKind(SpanKind.INTERNAL) + .hasName("TestMapper.select") + .hasAttributesSatisfyingExactly( + equalTo(SemanticAttributes.CODE_NAMESPACE, TestMapper.class.getName()), + equalTo(SemanticAttributes.CODE_FUNCTION, "select")))); } } diff --git a/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/RecordMapper.java b/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/RecordMapper.java deleted file mode 100644 index 3de3dce7b179..000000000000 --- a/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/RecordMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; - -import org.apache.ibatis.annotations.Update; - -public interface RecordMapper { - - @Update("CREATE TABLE dummy_record (id INT PRIMARY KEY, content VARCHAR(255))") - void updateRecord(); -} diff --git a/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/TestMapper.java b/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/TestMapper.java new file mode 100644 index 000000000000..1d5e858a91ce --- /dev/null +++ b/instrumentation/mybatis-3.2/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/mybatis/v3_2/TestMapper.java @@ -0,0 +1,14 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.mybatis.v3_2; + +import org.apache.ibatis.annotations.Select; + +public interface TestMapper { + + @Select("SELECT 1") + int select(); +}