From ec15f043c0744c90b4b0a7f31bb4129be1d64757 Mon Sep 17 00:00:00 2001 From: snmsmanager Date: Mon, 26 Feb 2024 23:23:37 +0530 Subject: [PATCH] DB2 Profiler Plugin added --- plugins/db2/.gitignore | 5 + plugins/db2/pom.xml | 25 ++ .../pinpoint/plugin/db2/DB2Config.java | 40 +++ .../pinpoint/plugin/db2/DB2JdbcUrlParser.java | 110 ++++++ .../pinpoint/plugin/db2/DB2Plugin.java | 314 ++++++++++++++++++ .../plugin/db2/DB2PluginConstants.java | 18 + .../pinpoint/plugin/db2/DB2TypeProvider.java | 19 ++ .../META-INF/pinpoint/type-provider.yml | 24 ++ ...p.pinpoint.bootstrap.plugin.ProfilerPlugin | 1 + ...inpoint.common.trace.TraceMetadataProvider | 1 + 10 files changed, 557 insertions(+) create mode 100644 plugins/db2/.gitignore create mode 100644 plugins/db2/pom.xml create mode 100644 plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2Config.java create mode 100644 plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2JdbcUrlParser.java create mode 100644 plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2Plugin.java create mode 100644 plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2PluginConstants.java create mode 100644 plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2TypeProvider.java create mode 100644 plugins/db2/src/main/resources/META-INF/pinpoint/type-provider.yml create mode 100644 plugins/db2/src/main/resources/META-INF/services/com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin create mode 100644 plugins/db2/src/main/resources/META-INF/services/com.navercorp.pinpoint.common.trace.TraceMetadataProvider diff --git a/plugins/db2/.gitignore b/plugins/db2/.gitignore new file mode 100644 index 000000000000..f6772784a0a9 --- /dev/null +++ b/plugins/db2/.gitignore @@ -0,0 +1,5 @@ +/target/ +/.settings/ +/.classpath +/.project +/*.iml \ No newline at end of file diff --git a/plugins/db2/pom.xml b/plugins/db2/pom.xml new file mode 100644 index 000000000000..b5bc450d8c5f --- /dev/null +++ b/plugins/db2/pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + + + com.navercorp.pinpoint + pinpoint-plugins + 3.0.0-SNAPSHOT + + + pinpoint-db2-plugin + pinpoint-db2-plugin + jar + + + + com.navercorp.pinpoint + pinpoint-bootstrap-core + provided + + + + diff --git a/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2Config.java b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2Config.java new file mode 100644 index 000000000000..0f14c5621828 --- /dev/null +++ b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2Config.java @@ -0,0 +1,40 @@ + +package com.navercorp.pinpoint.plugin.db2; + +import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcConfig; + + +public class DB2Config extends JdbcConfig { + private final boolean profileSetAutoCommit; + private final boolean profileCommit; + private final boolean profileRollback; + + public DB2Config(ProfilerConfig config) { + super(config.readBoolean("profiler.jdbc.DB2", false), + config.readBoolean("profiler.jdbc.DB2.tracesqlbindvalue", config.isTraceSqlBindValue()), + config.getMaxSqlBindValueSize()); + this.profileSetAutoCommit = config.readBoolean("profiler.jdbc.DB2.setautocommit", false); + this.profileCommit = config.readBoolean("profiler.jdbc.DB2.commit", false); + this.profileRollback = config.readBoolean("profiler.jdbc.DB2.rollback", false); + } + + public boolean isProfileSetAutoCommit() { + return profileSetAutoCommit; + } + + public boolean isProfileCommit() { + return profileCommit; + } + + public boolean isProfileRollback() { + return profileRollback; + } + + + @Override + public String toString() { + return "DB2Config [" + super.toString() + ", profileSetAutoCommit=" + profileSetAutoCommit + ", profileCommit=" + profileCommit + ", profileRollback=" + profileRollback + "]"; + } + +} \ No newline at end of file diff --git a/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2JdbcUrlParser.java b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2JdbcUrlParser.java new file mode 100644 index 000000000000..99ca3b531e49 --- /dev/null +++ b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2JdbcUrlParser.java @@ -0,0 +1,110 @@ + +package com.navercorp.pinpoint.plugin.db2; + +import com.navercorp.pinpoint.bootstrap.context.DatabaseInfo; +import com.navercorp.pinpoint.bootstrap.logging.PLogger; +import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParserV2; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo; +import com.navercorp.pinpoint.common.trace.ServiceType; + +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; + + +public class DB2JdbcUrlParser implements JdbcUrlParserV2 { + + + static final String DB2_URL_PREFIX = "jdbc:db2:"; + private static final Set TYPES = EnumSet.allOf(Type.class); + + private final PLogger logger = PLoggerFactory.getLogger(this.getClass()); + + @Override + public DatabaseInfo parse(String jdbcUrl) { + if (jdbcUrl == null) { + logger.info("jdbcUrl"); + return UnKnownDatabaseInfo.INSTANCE; + } + + Type type = getType(jdbcUrl); + if (type == null) { + logger.info("jdbcUrl has invalid prefix.(url:{}, valid prefixes:{}, {})", jdbcUrl, DB2_URL_PREFIX, DB2_URL_PREFIX); + return UnKnownDatabaseInfo.INSTANCE; + } + + try { + return parse0(jdbcUrl, type); + } catch (Exception e) { + logger.info("DB2JdbcUrl parse error. url: {}, Caused: {}", jdbcUrl, e.getMessage(), e); + return UnKnownDatabaseInfo.createUnknownDataBase(DB2PluginConstants.DB2,DB2PluginConstants.DB2_EXECUTE_QUERY, jdbcUrl); + } + } + + private DatabaseInfo parse0(String url, Type type) { + return parseNormal(url, type); + } + + private DatabaseInfo parseNormal(String url, Type type) { + + StringMaker maker = new StringMaker(url); + maker.after(type.getUrlPrefix()); + + String host = maker.after("//").before('/').value(); + List hostList = parseHost(host); + + String databaseId = maker.next().after('/').before('?').value(); + String normalizedUrl = maker.clear().before('?').value(); + return new DefaultDatabaseInfo(DB2PluginConstants.DB2, DB2PluginConstants.DB2_EXECUTE_QUERY, url, + normalizedUrl, hostList, databaseId); + } + + private List parseHost(String host) { + final int multiHost = host.indexOf(","); + if (multiHost == -1) { + return Collections.singletonList(host); + } + + String[] parsedHost = host.split(","); + return Arrays.asList(parsedHost); + } + + @Override + public ServiceType getServiceType() { + return DB2PluginConstants.DB2; + } + + private static Type getType(String jdbcUrl) { + for (Type type : TYPES) { + if (jdbcUrl.startsWith(type.getUrlPrefix())) { + return type; + } + } + return null; + } + + private enum Type { + DB2(DB2_URL_PREFIX); + + private final String urlPrefix; + private final String loadbalanceUrlPrefix; + + Type(String urlPrefix) { + this.urlPrefix = urlPrefix; + this.loadbalanceUrlPrefix = urlPrefix + "loadbalance:"; + } + + private String getUrlPrefix() { + return urlPrefix; + } + + private String getLoadbalanceUrlPrefix() { + return loadbalanceUrlPrefix; + } + } +} diff --git a/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2Plugin.java b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2Plugin.java new file mode 100644 index 000000000000..42558f3a298a --- /dev/null +++ b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2Plugin.java @@ -0,0 +1,314 @@ +package com.navercorp.pinpoint.plugin.db2; + +import static com.navercorp.pinpoint.common.util.VarArgs.va; + +import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass; +import com.navercorp.pinpoint.bootstrap.instrument.InstrumentException; +import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod; +import com.navercorp.pinpoint.bootstrap.instrument.Instrumentor; +import com.navercorp.pinpoint.bootstrap.instrument.MethodFilter; +import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback; +import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplate; +import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplateAware; +import com.navercorp.pinpoint.bootstrap.interceptor.Interceptor; +import com.navercorp.pinpoint.bootstrap.interceptor.scope.ExecutionPolicy; +import com.navercorp.pinpoint.bootstrap.logging.PLogger; +import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; +import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin; +import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPluginSetupContext; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.BindValueAccessor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor; + +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.PreparedStatementBindingMethodFilter; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.PreparedStatementBindingMethodFilter; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.PreparedStatementBindVariableInterceptor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.PreparedStatementExecuteQueryInterceptor; + +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementExecuteQueryInterceptor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementExecuteUpdateInterceptor; + + + +import com.navercorp.pinpoint.bootstrap.plugin.util.InstrumentUtils; + +import java.security.ProtectionDomain; +import java.util.List; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementCreateInterceptor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.ConnectionCloseInterceptor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.PreparedStatementCreateInterceptor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.TransactionSetAutoCommitInterceptor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.TransactionCommitInterceptor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.TransactionRollbackInterceptor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.DriverConnectInterceptorV2; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.ParsingResultAccessor; +import com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.CallableStatementRegisterOutParameterInterceptor; + +import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod; + +public class DB2Plugin implements ProfilerPlugin, TransformTemplateAware { + + private static final String DB2_SCOPE = DB2PluginConstants.DB2_SCOPE; + + private final PLogger logger = PLoggerFactory.getLogger(this.getClass()); + + private final DB2JdbcUrlParser jdbcUrlParser = new DB2JdbcUrlParser(); + + private TransformTemplate transformTemplate; + + @Override + public void setup(ProfilerPluginSetupContext context) { + DB2Config config = new DB2Config(context.getConfig()); + if (!config.isPluginEnable()) { + logger.info(">>>>>>>>>>>>>>>>>>>>>>>>{} disabled", this.getClass().getSimpleName()); + return; + } + logger.info(">>>>>>>>>>>>>>>>>>>>>>{} config:{}", this.getClass().getSimpleName(), config); + + context.addJdbcUrlParser(jdbcUrlParser); + + addConnectionTransformer(); + addDriverTransformer(); + addPreparedStatementTransformer(); + addCallableStatementTransformer(); + addStatementTransformer(); + + + } + + private void addConnectionTransformer() { + logger.info(">>>>>>>>>>>>>>>>>>>>>> IN SIDE addConnectionTransformer"); + transformTemplate.transform("com.ibm.db2.jcc.DB2Connection", + DB2ConnectionTransform.class); + } + + public static class DB2ConnectionTransform implements TransformCallback { + + @Override + public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, + Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) + throws InstrumentException { + DB2Config config = new DB2Config(instrumentor.getProfilerConfig()); + InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer); + + if (!target.isInterceptable()) { + return null; + } + + target.addField(DatabaseInfoAccessor.class); + + // close + InstrumentUtils.findMethod(target, "close") + .addScopedInterceptor(ConnectionCloseInterceptor.class, DB2_SCOPE); + + // createStatement + final Class statementCreate = StatementCreateInterceptor.class; + InstrumentUtils.findMethod(target, "createStatement") + .addScopedInterceptor(statementCreate, DB2_SCOPE); + InstrumentUtils.findMethod(target, "createStatement", "int", "int") + .addScopedInterceptor(statementCreate, DB2_SCOPE); + InstrumentUtils.findMethod(target, "createStatement", "int", "int", "int") + .addScopedInterceptor(statementCreate, DB2_SCOPE); + + // preparedStatement + final Class preparedStatementCreate = PreparedStatementCreateInterceptor.class; + InstrumentUtils.findMethod(target, "prepareStatement", "java.lang.String") + .addScopedInterceptor(preparedStatementCreate, DB2_SCOPE); + InstrumentUtils.findMethod(target, "prepareStatement", "java.lang.String", "int") + .addScopedInterceptor(preparedStatementCreate, DB2_SCOPE); + InstrumentUtils.findMethod(target, "prepareStatement", "java.lang.String", "int[]") + .addScopedInterceptor(preparedStatementCreate, DB2_SCOPE); + InstrumentUtils + .findMethod(target, "prepareStatement", "java.lang.String", "java.lang.String[]") + .addScopedInterceptor(preparedStatementCreate, DB2_SCOPE); + InstrumentUtils.findMethod(target, "prepareStatement", "java.lang.String", "int", "int") + .addScopedInterceptor(preparedStatementCreate,DB2_SCOPE); + InstrumentUtils + .findMethod(target, "prepareStatement", "java.lang.String", "int", "int", "int") + .addScopedInterceptor(preparedStatementCreate, DB2_SCOPE); + + // preparecall + InstrumentUtils.findMethod(target, "prepareCall", "java.lang.String") + .addScopedInterceptor(preparedStatementCreate, DB2_SCOPE); + InstrumentUtils.findMethod(target, "prepareCall", "java.lang.String", "int", "int") + .addScopedInterceptor(preparedStatementCreate, DB2_SCOPE); + InstrumentUtils + .findMethod(target, "prepareCall", "java.lang.String", "int", "int", "int") + .addScopedInterceptor(preparedStatementCreate, DB2_SCOPE); + + if (config.isProfileSetAutoCommit()) { + InstrumentUtils.findMethod(target, "setAutoCommit", "boolean") + .addScopedInterceptor(TransactionSetAutoCommitInterceptor.class, DB2_SCOPE); + } + + if (config.isProfileCommit()) { + InstrumentUtils.findMethod(target, "commit") + .addScopedInterceptor(TransactionCommitInterceptor.class, DB2_SCOPE); + } + + if (config.isProfileRollback()) { + InstrumentUtils.findMethod(target, "rollback") + .addScopedInterceptor(TransactionRollbackInterceptor.class, DB2_SCOPE); + } + + return target.toBytecode(); + } + + }; + + + private void addDriverTransformer() { + logger.info(">>>>>>>>>>>>>>>>>>>>>> IN SIDE addDriverTransformer"); + transformTemplate.transform("com.ibm.db2.jcc.DB2Driver", DriverTransformer.class); + } + + + public static class DriverTransformer implements TransformCallback { + + @Override + public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, + Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException { + InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer); + + target.addField(DatabaseInfoAccessor.class); + + InstrumentUtils.findMethod( target, + "connect", + "java.lang.String", + "java.util.Properties").addScopedInterceptor(DriverConnectInterceptorV2.class, va(DB2PluginConstants.DB2, true), DB2_SCOPE, ExecutionPolicy.ALWAYS); + + return target.toBytecode(); + } + }; + + + private void addPreparedStatementTransformer() { + logger.info(">>>>>>>>>>>>>>>>>>>>>> IN SIDE addPreparedStatementTransformer"); + transformTemplate.transform("com.ibm.db2.jcc.DB2PreparedStatement", + PreparedStatementTransform.class); + } + + + public static class PreparedStatementTransform implements TransformCallback { + + @Override + public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, + Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) + throws InstrumentException { + + DB2Config config = new DB2Config(instrumentor.getProfilerConfig()); + InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer); + + target.addField(DatabaseInfoAccessor.class); + target.addField(ParsingResultAccessor.class); + target.addField(BindValueAccessor.class); + + int maxBindValueSize = config.getMaxSqlBindValueSize(); + + final Class preparedStatementInterceptor = PreparedStatementExecuteQueryInterceptor.class; + InstrumentUtils.findMethod(target, "execute") + .addScopedInterceptor(preparedStatementInterceptor, va(maxBindValueSize), DB2_SCOPE); + InstrumentUtils.findMethod(target, "executeQuery") + .addScopedInterceptor(preparedStatementInterceptor, va(maxBindValueSize), DB2_SCOPE); + InstrumentUtils.findMethod(target, "executeUpdate") + .addScopedInterceptor(preparedStatementInterceptor, va(maxBindValueSize), DB2_SCOPE); + + if (config.isTraceSqlBindValue()) { + final PreparedStatementBindingMethodFilter excludes = PreparedStatementBindingMethodFilter + .excludes("setRowId", "setNClob", "setSQLXML"); + + final List declaredMethods = target.getDeclaredMethods(excludes); + for (InstrumentMethod method : declaredMethods) { + method.addScopedInterceptor(PreparedStatementBindVariableInterceptor.class, DB2_SCOPE, + ExecutionPolicy.BOUNDARY); + } + } + + return target.toBytecode(); + } + } + + ; + + + private void addStatementTransformer() { + logger.info(">>>>>>>>>>>>>>>>>>>>>> IN SIDE addStatementTransformer"); + + transformTemplate.transform("com.ibm.db2.jcc.DB2ServerStatement", + DB2StatementTransform.class); + } + + private void addCallableStatementTransformer() { + logger.info(">>>>>>>>>>>>>>>>>>>>>> IN SIDE addCallableStatementTransformer"); + transformTemplate.transform("com.ibm.db2.jcc.DB2CallableStatement", + DB2CallableStatementTransform.class); + } + + + + public static class DB2StatementTransform implements TransformCallback { + + @Override + public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) + throws InstrumentException { + InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer); + + if (!target.isInterceptable()) { + return null; + } + + target.addField(DatabaseInfoAccessor.class); + + final Class executeQueryInterceptor = StatementExecuteQueryInterceptor.class; + InstrumentUtils.findMethod(target, "executeQuery", "java.lang.String") + .addScopedInterceptor(executeQueryInterceptor, DB2_SCOPE); + + final Class executeUpdateInterceptor = StatementExecuteUpdateInterceptor.class; + InstrumentUtils.findMethod(target, "executeUpdate", "java.lang.String") + .addScopedInterceptor(executeUpdateInterceptor, DB2_SCOPE); + InstrumentUtils.findMethod(target, "executeUpdate", "java.lang.String", "int") + .addScopedInterceptor(executeUpdateInterceptor, DB2_SCOPE); + InstrumentUtils.findMethod(target, "execute", "java.lang.String") + .addScopedInterceptor(executeUpdateInterceptor, DB2_SCOPE); + InstrumentUtils.findMethod(target, "execute", "java.lang.String", "int") + .addScopedInterceptor(executeUpdateInterceptor, DB2_SCOPE); + + return target.toBytecode(); + } + }; + + + public static class DB2CallableStatementTransform implements TransformCallback { + + @Override + public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, + Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) + throws InstrumentException { + InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer); + + if (!target.isInterceptable()) { + return null; + } + + target.addField(DatabaseInfoAccessor.class); + target.addField(ParsingResultAccessor.class); + target.addField(BindValueAccessor.class); + + + final Class callableStatementInterceptor = CallableStatementRegisterOutParameterInterceptor.class; + InstrumentUtils.findMethod(target, "registerOutParameter", "int", "int") + .addScopedInterceptor(callableStatementInterceptor, DB2_SCOPE); + InstrumentUtils.findMethod(target, "registerOutParameter", "int", "int", "int") + .addScopedInterceptor(callableStatementInterceptor, DB2_SCOPE); + InstrumentUtils.findMethod(target, "registerOutParameter", "int", "int", "java.lang.String") + .addScopedInterceptor(callableStatementInterceptor, DB2_SCOPE); + + return target.toBytecode(); + } + }; + + + @Override + public void setTransformTemplate(TransformTemplate transformTemplate) { + this.transformTemplate = transformTemplate; + } +} \ No newline at end of file diff --git a/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2PluginConstants.java b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2PluginConstants.java new file mode 100644 index 000000000000..432983dc36d1 --- /dev/null +++ b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2PluginConstants.java @@ -0,0 +1,18 @@ +package com.navercorp.pinpoint.plugin.db2; + +import static com.navercorp.pinpoint.common.trace.ServiceTypeProperty.*; + +import com.navercorp.pinpoint.common.trace.ServiceType; +import com.navercorp.pinpoint.common.trace.ServiceTypeFactory; + + +public final class DB2PluginConstants { + private DB2PluginConstants() { + } + + public static final String DB2_SCOPE = "DB2_JDBC"; + + public static final ServiceType DB2 = ServiceTypeFactory.of(2900, "DB2", TERMINAL, INCLUDE_DESTINATION_ID); + public static final ServiceType DB2_EXECUTE_QUERY = ServiceTypeFactory.of(2901, "DB2_EXECUTE_QUERY", + "DB2", TERMINAL, RECORD_STATISTICS, INCLUDE_DESTINATION_ID); +} diff --git a/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2TypeProvider.java b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2TypeProvider.java new file mode 100644 index 000000000000..1543aeaee52b --- /dev/null +++ b/plugins/db2/src/main/java/com/navercorp/pinpoint/plugin/db2/DB2TypeProvider.java @@ -0,0 +1,19 @@ + +package com.navercorp.pinpoint.plugin.db2; + +import com.navercorp.pinpoint.common.trace.AnnotationKey; +import com.navercorp.pinpoint.common.trace.AnnotationKeyMatchers; +import com.navercorp.pinpoint.common.trace.TraceMetadataProvider; +import com.navercorp.pinpoint.common.trace.TraceMetadataSetupContext; + + +public class DB2TypeProvider implements TraceMetadataProvider { + + @Override + public void setup(TraceMetadataSetupContext context) { + context.addServiceType(DB2PluginConstants.DB2, AnnotationKeyMatchers.exact(AnnotationKey.ARGS0)); + context.addServiceType(DB2PluginConstants.DB2_EXECUTE_QUERY, AnnotationKeyMatchers.exact(AnnotationKey.ARGS0)); + AnnotationKeyMatchers.exact(AnnotationKey.ARGS0); + } + +} diff --git a/plugins/db2/src/main/resources/META-INF/pinpoint/type-provider.yml b/plugins/db2/src/main/resources/META-INF/pinpoint/type-provider.yml new file mode 100644 index 000000000000..89e25912f4c3 --- /dev/null +++ b/plugins/db2/src/main/resources/META-INF/pinpoint/type-provider.yml @@ -0,0 +1,24 @@ +serviceTypes: + - code: 2902 + name: 'DB2_JDBC' + property: + terminal: true + includeDestinationId: true + - code: 2903 + name: 'DB2_JDBC_QUERY' + desc: 'DB2SERVER' + property: + terminal: true + includeDestinationId: true + recordStatistics: true + + +annotationKeys: + - code: 10998 + name: 'MyValue' + - code: 10995 + name: 'MY_ARGUMENT' + - code: 10996 + name: 'MY_PROCEDURE' + - code: 10997 + name: 'MY_RESULT' \ No newline at end of file diff --git a/plugins/db2/src/main/resources/META-INF/services/com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin b/plugins/db2/src/main/resources/META-INF/services/com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin new file mode 100644 index 000000000000..73fed3736b26 --- /dev/null +++ b/plugins/db2/src/main/resources/META-INF/services/com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin @@ -0,0 +1 @@ +com.navercorp.pinpoint.plugin.db2.DB2Plugin \ No newline at end of file diff --git a/plugins/db2/src/main/resources/META-INF/services/com.navercorp.pinpoint.common.trace.TraceMetadataProvider b/plugins/db2/src/main/resources/META-INF/services/com.navercorp.pinpoint.common.trace.TraceMetadataProvider new file mode 100644 index 000000000000..d93c2d8e44be --- /dev/null +++ b/plugins/db2/src/main/resources/META-INF/services/com.navercorp.pinpoint.common.trace.TraceMetadataProvider @@ -0,0 +1 @@ +com.navercorp.pinpoint.plugin.db2.DB2TypeProvider \ No newline at end of file