pinpoint-apm / pinpoint

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

I am making a mssql-jdbc plugin #6369

Closed gwagdalf closed 4 years ago

gwagdalf commented 4 years ago

Which module is your feature request related to? mssql-jdbc plugin

Is your feature request related to a problem? It can profile mssql-jdbc connection, query and bindvalue.

Describe the solution you'd like I'm making now

Describe alternatives you've considered I have seen that the mssql-jdbc module is profiled, but I need to supplement some features. and I would also like some help how to write test code. image

Additional context The code is not complete, but I wonder if I can pull a request for code review.

Plus, the code for ServiceType is

The existing mssql jtds are 2200, 2201. mssql-jtds code

emeroad commented 4 years ago

@gwagdalf Hello~

UNDEFINED problem

emeroad commented 4 years ago

@gwagdalf Hello~ Can I know which version of Microsoft JDBC Driver is supported by mssql-plugin? To set a minimum JDK version of msql-plugin, Microsoft JDBC Driver version is required. eg) 7.0.0~, 7.4.x

https://docs.microsoft.com/en-us/sql/connect/jdbc/system-requirements-for-the-jdbc-driver?view=sql-server-ver15

// kor link https://docs.microsoft.com/ko-kr/sql/connect/jdbc/system-requirements-for-the-jdbc-driver?view=sql-server-ver15

7.0.0

JAR JDBC Version Compliance Recommended Java Version Description
mssql-jdbc-7.4.1.jre8.jar 4.2 8 Requires a Java Runtime Environment (JRE) 1.8. Using JRE 1.7 or lower throws an exception.New Features in 7.4 include: JDK 12 support, NTLM authentication, and useFmtOnly.
mssql-jdbc-7.4.1.jre11.jar 4.3 11 Requires a Java Runtime Environment (JRE) 11.0. Using JRE 10.0 or lower throws an exception.New Features in 7.4 include: JDK 12 support, NTLM authentication, and useFmtOnly.
mssql-jdbc-7.4.1.jre12.jar 4.3 12 Requires a Java Runtime Environment (JRE) 12.0. Using JRE 11.0 or lower throws an exception.New Features in 7.4 include: JDK 12 support, NTLM authentication, and useFmtOnly.

6.4.0

JAR JDBC Version Compliance Recommended Java Version Description
mssql-jdbc-6.4.0.jre7.jar 4.1 7 Requires a Java Runtime Environment (JRE) 7.0. Using JRE 6.0 or lower throws an exception.New Features in 6.4 include: Azure AD authentication for Linux, Principal/Password method for Kerberos, automatic detection of REALM in SPN for Cross-Domain authentication, Kerberos Constrained Delegation, Query Timeout, Socket Timeout, and prepared statement handle re-use.
mssql-jdbc-6.4.0.jre8.jar 4.2 8 Requires a Java Runtime Environment (JRE) 8.0. Using JRE 7.0 or lower throws an exception.New Features in 6.4 include: Azure AD authentication for Linux, Principal/Password method for Kerberos, automatic detection of REALM in SPN for Cross-Domain authentication, Kerberos Constrained Delegation, Query Timeout, Socket Timeout, and prepared statement handle re-use.
mssql-jdbc-6.4.0.jre9.jar 4.3 9 Requires a Java Runtime Environment (JRE) 9.0. Using JRE 8.0 or lower throws an exception.New Features in 6.4 include: Azure AD authentication for Linux, Principal/Password method for Kerberos, automatic detection of REALM in SPN for Cross-Domain authentication, Kerberos Constrained Delegation, Query Timeout, Socket Timeout, and prepared statement handle re-use.
gwagdalf commented 4 years ago

I'd checked it works in-house applications with mssql-jdbc-7.0.0.jre8.jar.

In addition, I'll try to write mssql-it code by referring to mariadb-integration-test-code. https://github.com/naver/pinpoint/tree/master/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/mariadb

gwagdalf commented 4 years ago

I can't run mariadb integration test. and also can't run any other integration-test class either. ex : https://github.com/naver/pinpoint/blob/master/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/mariadb/MariaDB_2_4_x_IT.java

The error message is:

"C:\Program Files\Zulu\zulu-8\bin\java.exe" -ea -Dpinpoint.profiler.profiles.active=run-integration-test -Dfile.encoding=UTF-8 -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\hgwag\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\193.5233.102\lib\idea_rt.jar=52961:C:\Users\hgwag\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\193.5233.102\bin -classpath C:\Users\hgwag\AppData\Local\Temp\classpath1850343592.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 com.navercorp.pinpoint.plugin.jdbc.mariadb.MariaDB_2_4_x_IT

Command: [C:\Program Files\Zulu\zulu-8\bin\java.exe, -Xmx1024m, -XX:MaxPermSize=512m, -cp, , -javaagent:C:\git19\ecosystem\_pinpoint\gwagdalf-pinpoint\agent-it\.\..\agent\target\pinpoint-agent-2.0.0-SNAPSHOT\pinpoint-bootstrap-2.0.0-SNAPSHOT.jar=AGENT_TYPE=PLUGIN_TEST, -Dpinpoint.agentId=build.test.0, -Dpinpoint.applicationName=test, -DmavenDependencyResolverClassPaths=, -DtestLocation=C:\git19\ecosystem\_pinpoint\gwagdalf-pinpoint\agent-it\target\test-classes, -DtestClazzName=com.navercorp.pinpoint.plugin.jdbc.mariadb.MariaDB_2_4_x_IT, -Dpinpoint.profiler.profiles.active=run-integration-test, -Dfile.encoding=UTF-8, com.navercorp.pinpoint.test.plugin.shared.SharedPinpointPluginTest, mariadb-java-client-2.4.2:child:8=org.mariadb.jdbc:mariadb-java-client:2.4.2;ch.vorburger.mariaDB4j:mariaDB4j:2.2.2;, mariadb-java-client-2.5.1:child:8=org.mariadb.jdbc:mariadb-java-client:2.5.1;ch.vorburger.mariaDB4j:mariaDB4j:2.2.2;, mariadb-java-client-2.4.3:child:8=org.mariadb.jdbc:mariadb-java-client:2.4.3;ch.vorburger.mariaDB4j:mariaDB4j:2.2.2;, mariadb-java-client-2.5.2:child:8=org.mariadb.jdbc:mariadb-java-client:2.5.2;ch.vorburger.mariaDB4j:mariaDB4j:2.2.2;, mariadb-java-client-2.4.4:child:8=org.mariadb.jdbc:mariadb-java-client:2.4.4;ch.vorburger.mariaDB4j:mariaDB4j:2.2.2;, mariadb-java-client-2.5.3:child:8=org.mariadb.jdbc:mariadb-java-client:2.5.3;ch.vorburger.mariaDB4j:mariaDB4j:2.2.2;, mariadb-java-client-2.4.0:child:8=org.mariadb.jdbc:mariadb-java-client:2.4.0;ch.vorburger.mariaDB4j:mariaDB4j:2.2.2;, mariadb-java-client-2.4.1:child:8=org.mariadb.jdbc:mariadb-java-client:2.4.1;ch.vorburger.mariaDB4j:mariaDB4j:2.2.2;, mariadb-java-client-2.5.0:child:8=org.mariadb.jdbc:mariadb-java-client:2.5.0;ch.vorburger.mariaDB4j:mariaDB4j:2.2.2;]
CommandSize: 1744

Error: Could not find or load base class com.navercorp.pinpoint.test.plugin.shared.SharedPinpointPluginTest

could you help me how to run agent-it? I don't know how to run agent-it test, so I can't start mssql-it.

In addition, the following error (Address already in use) occurs when debugging Intellij.

image

emeroad commented 4 years ago

Error: Could not find or load base class com.navercorp.pinpoint.test.plugin.shared.SharedPinpointPluginTest

  • Build seems to be something wrong. Try to build again

Address already in use

  • ItTest creates a child process for the Agent attatch. The debug port seems to be in use during process creation. Make sure you are using 5101296 port
emeroad commented 4 years ago

To debug ITTest, you must attatch the RemoteDebugger. image

image

emeroad commented 4 years ago

@gwagdalf Hello~ I added an integration test for mssql-jdbc-driver-plugin https://github.com/gwagdalf/pinpoint/commit/2eaa84ff67b0cf2dd7e1d03513ed23e418a8c909

I have confirmed that mssql-plugin works fine in test environment. Would you like to modify mssql.properties and run a test? https://github.com/gwagdalf/pinpoint/blob/2eaa84ff67b0cf2dd7e1d03513ed23e418a8c909/agent-it8/src/test/resources/database/mssql.properties

# ms sqlserver
mssqlserver.url=${URL_FOR_TEST}
mssqlserver.user=${USER_FOR_TEST}
mssqlserver.password=${PASSWORD_FOR_TEST}

image

gwagdalf commented 4 years ago

Wow! thank you so much. Still, I wasn't able to run the integration test, so I was stuck and doing other things.​ Give me more time.

gwagdalf commented 4 years ago

I checked that pull request is merged.

Agent-debug and aether is too hard for me. I think I have to study more.

I suffered from the following problems. First, @Repository default is central (http://central.maven.org/maven2/, default, releases+snapshots) That's not work for me so I need to add @Repository({private repo},{"https://repo1.maven.org/maven2/"}) It took so long to know.

Second, aether depedency problems like this.

 Caused by: org.eclipse.aether.collection.DependencyCollectionException: 
Failed to collect dependencies at com.microsoft.sqlserver:mssql-jdbc:jar:6.1.0.jre8 
-> com.microsoft.azure:azure-keyvault:jar:0.9.3 
-> com.microsoft.azure:adal4j:jar:1.0.0 
-> commons-codec:commons-codec:jar:[1.10,) is omiited for duplicate

Third, the lack of understanding of the agent-test process, still I stuck by intellij debug.

Now, I will take more time and study to prepare it-tests.

Thank you for your time and effort. I really appreciate it. Happy lunar new year!

torreso commented 4 years ago

@gwagdalf @emeroad Thank you for your supports. Could you tell me how to set up my system? I using pinpoint 1.8.5 docker version. (I'm not a developer)

emeroad commented 4 years ago

@gwagdalf I fixed the maven central address issue. Thank you.

emeroad commented 4 years ago

6466