pinpoint-apm / pinpoint

APM, (Application Performance Management) tool for large-scale distributed systems.
https://pinpoint-apm.gitbook.io/
Apache License 2.0
13.43k stars 3.76k forks source link

Implementing DB2 Profiler Plugin #10707

Open snmsmanager opened 9 months ago

snmsmanager commented 9 months ago

I've created sample DB2 plugin by using existing MariaDB plugin and I've successfully compiled and generated plugin jar file. can you please explain the steps needed to Implement this Profiler Plugin? Is it sufficient to copy DB2 plugin jar file under agent/plugins?

emeroad commented 9 months ago

Yes, just copy the jar file. If you place the jar in agent/plugins, it will be automatically loaded by ServiceLoader.

https://github.com/pinpoint-apm/pinpoint/tree/master/plugins/mysql-jdbc/src/main/resources/META-INF/services Don't forget the services config file as well.

snmsmanager commented 9 months ago

DB2Plugin.java.txt @emeroad thank for the instruction.

I’ve copied “pinpoint-db2-plugin-3.0.0-SNAPSHOT.jar” to agent’s plugin location and it is registered properly. Now I’m getting below error for addDriverTransformer method in **** file. I'm not able to see any connections related to DB2 in corelation map.
sLoader@97a145b ctxCl:org.springframework.boot.loader.LaunchedURLClassLoader@97a145b agentCl:ParallelClassLoader@1510467688{name='pinpoint.agent'} Cause:Cannot find suitable constructor for com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.DriverConnectInterceptorV2 com.navercorp.pinpoint.exception.PinpointException: Cannot find suitable constructor for com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.DriverConnectInterceptorV2 at com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory.byConstructor(AutoBindingObjectFactory.java:86) ~[pinpoint-profiler-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory.createInstance(AutoBindingObjectFactory.java:79) ~[pinpoint-profiler-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory.newInterceptor(AnnotatedInterceptorFactory.java:118) ~[pinpoint-profiler-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at com.navercorp.pinpoint.profiler.instrument.ASMMethod.createInterceptor(ASMMethod.java:146) ~[pinpoint-profiler-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at com.navercorp.pinpoint.profiler.instrument.ASMMethod.newInterceptor(ASMMethod.java:138) ~[pinpoint-profiler-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at com.navercorp.pinpoint.profiler.instrument.ASMMethod.addScopedInterceptor(ASMMethod.java:287) ~[pinpoint-profiler-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at com.navercorp.pinpoint.plugin.db2.DB2Plugin$DriverTransformer.doInTransform(DB2Plugin.java:177) ~[pinpoint-db2-plugin-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at com.navercorp.pinpoint.profiler.plugin.MatchableClassFileTransformerDelegate.transform(MatchableClassFileTransformerDelegate.java:64) ~[pinpoint-profiler-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at com.navercorp.pinpoint.profiler.transformer.BaseClassFileTransformer.transform(BaseClassFileTransformer.java:56) [pinpoint-profiler-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at com.navercorp.pinpoint.profiler.transformer.DefaultClassFileTransformerDispatcher.transform(DefaultClassFileTransformerDispatcher.java:89) [pinpoint-profiler-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT] at sun.instrument.TransformerManager.transform(TransformerManager.java:188) [?:1.8.0_402] at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428) [?:1.8.0_402] at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_402] at java.lang.ClassLoader.defineClass(ClassLoader.java:756) [?:1.8.0_402] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [?:1.8.0_402] at java.net.URLClassLoader.defineClass(URLClassLoader.java:473) [?:1.8.0_402] at java.net.URLClassLoader.access$100(URLClassLoader.java:74) [?:1.8.0_402] at java.net.URLClassLoader$1.run(URLClassLoader.java:369) [?:1.8.0_402] at java.net.URLClassLoader$1.run(URLClassLoader.java:363) [?:1.8.0_402] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_402] at java.net.URLClassLoader.findClass(URLClassLoader.java:362) [?:1.8.0_402] at java.lang.ClassLoader.loadClass(ClassLoader.java:418) [?:1.8.0_402] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) [spring-boot-db2-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [?:1.8.0_402] at org.springframework.util.ClassUtils.forName(ClassUtils.java:250) [spring-core-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]

emeroad commented 9 months ago

Please submit a PR for db2 plugn on pinpoint github Let's run the reproduction code.

snmsmanager commented 9 months ago

Please submit a PR for db2 plugn on pinpoint github Let's run the reproduction code.

10719 please check.