Skip to content

Commit

Permalink
Merge pull request scouter-project#483 from scouter-project/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
gunlee01 authored Jul 21, 2018
2 parents 126bb19 + 031d5e4 commit 662ba46
Show file tree
Hide file tree
Showing 205 changed files with 47,083 additions and 45,597 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.scouter-project</groupId>
<artifactId>scouter-parent</artifactId>
<version>1.8.6</version>
<version>1.9.0</version>
<packaging>pom</packaging>

<name>SCOUTER APM</name>
Expand Down
2 changes: 1 addition & 1 deletion scouter.agent.batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.github.scouter-project</groupId>
<artifactId>scouter-parent</artifactId>
<version>1.8.6</version>
<version>1.9.0</version>
</parent>

<artifactId>scouter-agent-batch</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scouter.agent.host/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.github.scouter-project</groupId>
<artifactId>scouter-parent</artifactId>
<version>1.8.6</version>
<version>1.9.0</version>
</parent>

<artifactId>scouter-agent-host</artifactId>
Expand Down
10 changes: 9 additions & 1 deletion scouter.agent.java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.github.scouter-project</groupId>
<artifactId>scouter-parent</artifactId>
<version>1.8.6</version>
<version>1.9.0</version>
</parent>

<artifactId>scouter-agent-java</artifactId>
Expand All @@ -17,6 +17,7 @@

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<scouter.http.jar>scouter.http.jar</scouter.http.jar>
<scouter.jdbc.jar>scouter.jdbc.jar</scouter.jdbc.jar>
<scouter.httpclient.jar>scouter.httpclient.jar</scouter.httpclient.jar>
<scouter.tools.jar>scouter.tools.jar</scouter.tools.jar>

Expand Down Expand Up @@ -188,6 +189,11 @@
<include name="scouter/xtra/http/*.class" />
</fileset>
</jar>
<jar destfile="${project.build.directory}/${scouter.jdbc.jar}">
<fileset dir="${project.build.outputDirectory}">
<include name="scouter/xtra/jdbc/*.class" />
</fileset>
</jar>
<jar destfile="${project.build.directory}/${scouter.httpclient.jar}">
<fileset dir="${project.build.outputDirectory}">
<include name="scouter/xtra/httpclient/*.class" />
Expand Down Expand Up @@ -215,6 +221,7 @@
<jar destfile="${final.jar.name.xtra}">
<fileset dir="${project.build.directory}">
<include name="${scouter.http.jar}" />
<include name="${scouter.jdbc.jar}" />
<include name="${scouter.httpclient.jar}" />
<include name="${scouter.tools.jar}" />
</fileset>
Expand All @@ -232,6 +239,7 @@
<copy file="${final.jar.name}" tofile="${final.jar.name.shade}" overwrite="true" verbose="true" />
<copy file="${final.jar.name.xtra}" tofile="${final.jar.name}" overwrite="true" verbose="true" />
<delete file="${project.build.directory}/${scouter.http.jar}" />
<delete file="${project.build.directory}/${scouter.jdbc.jar}" />
<delete file="${project.build.directory}/${scouter.httpclient.jar}" />
<delete file="${project.build.directory}/${scouter.tools.jar}" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import scouter.agent.asm.IASM;
import scouter.agent.asm.InitialContextASM;
import scouter.agent.asm.JDBCConnectionOpenASM;
import scouter.agent.asm.JDBCGetConnectionASM;
import scouter.agent.asm.JDBCDriverASM;
import scouter.agent.asm.JDBCGetConnectionASM;
import scouter.agent.asm.JDBCPreparedStatementASM;
import scouter.agent.asm.JDBCResultSetASM;
import scouter.agent.asm.JDBCStatementASM;
Expand All @@ -49,6 +49,7 @@
import scouter.agent.asm.asyncsupport.RequestStartAsyncASM;
import scouter.agent.asm.asyncsupport.executor.ExecutorServiceASM;
import scouter.agent.asm.asyncsupport.spring.SpringAsyncExecutionASM;
import scouter.agent.asm.asyncsupport.spring.SpringAsyncExecutionAspectSupportDoSubmitASM;
import scouter.agent.asm.redis.JedisConnectionASM;
import scouter.agent.asm.redis.RedisCacheKeyASM;
import scouter.agent.asm.redis.RedisKeyASM;
Expand Down Expand Up @@ -101,11 +102,13 @@ public static void reload() {
temp.add(new RequestStartAsyncASM());
temp.add(new AsyncContextDispatchASM());

//TODO temporary block
temp.add(new JDBCPreparedStatementASM());
temp.add(new JDBCResultSetASM());
temp.add(new JDBCStatementASM());
temp.add(new SqlMapASM());
temp.add(new UserTxASM());

temp.add(new JDBCGetConnectionASM());
temp.add(new JDBCConnectionOpenASM());
temp.add(new JDBCDriverASM());
Expand All @@ -120,8 +123,10 @@ public static void reload() {
temp.add(new ApicallInfoASM());
temp.add(new ApicallSpringHttpAccessorASM());
temp.add(new SpringAsyncExecutionASM());
temp.add(new SpringAsyncExecutionAspectSupportDoSubmitASM());
temp.add(new CallRunnableASM());
temp.add(new ExecutorServiceASM());

temp.add(new RedisKeyASM());
temp.add(new RedisCacheKeyASM());
temp.add(new JedisConnectionASM());
Expand Down
13 changes: 12 additions & 1 deletion scouter.agent.java/src/main/java/scouter/agent/Configure.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ public final static synchronized Configure getInstance() {
// @ConfigDesc("Activating profile summary function")
// public boolean profile_summary_mode_enabled = false;

@ConfigDesc("Calculating CPU time by profile")
@ConfigDesc("Profiling the memory usage of each method")
public boolean profile_thread_cputime_enabled = false;
@ConfigDesc("Profiling the memory usage of each service")
public boolean profile_thread_memory_usage_enabled = true;
@ConfigDesc("ThreadStack profile for open socket")
public boolean profile_socket_open_fullstack_enabled = false;
@ConfigDesc("ThreadStack profile for a certain port of open socket")
Expand Down Expand Up @@ -184,6 +186,8 @@ public final static synchronized Configure getInstance() {
@ConfigDesc("")
public boolean _profile_fullstack_sql_connection_enabled = false;
@ConfigDesc("")
public boolean _profile_fullstack_sql_execute_debug_enabled = false;
@ConfigDesc("")
public boolean profile_fullstack_rs_leak_enabled = false;
@ConfigDesc("")
public boolean profile_fullstack_stmt_leak_enabled = false;
Expand Down Expand Up @@ -380,6 +384,10 @@ public final static synchronized Configure getInstance() {
@ConfigDesc("Do not discard error even if it's discard pattern.")
public boolean xlog_discard_service_show_error = true;

@ConfigDesc("XLog fully discard service patterns\nNo XLog data, No apply to TPS and summary.\neg) /user/{userId}<GET>,/device/*")
@ConfigValueType(ValueType.COMMA_SEPARATED_VALUE)
public String xlog_fully_discard_service_patterns = "";

//Alert
@ConfigDesc("Limited length of alert message")
public int alert_message_length = 3000;
Expand Down Expand Up @@ -792,6 +800,7 @@ private void apply() {

this.mgr_static_content_extensions = getValue("mgr_static_content_extensions", "js, htm, html, gif, png, jpg, css");
this.profile_thread_cputime_enabled = getBoolean("profile_thread_cputime_enabled", false);
this.profile_thread_memory_usage_enabled = getBoolean("profile_thread_memory_usage_enabled", true);
this.profile_socket_open_fullstack_enabled = getBoolean("profile_socket_open_fullstack_enabled", false);
this.trace_background_socket_enabled = getBoolean("trace_background_socket_enabled", true);
this.profile_socket_open_fullstack_port = getInt("profile_socket_open_fullstack_port", 0);
Expand Down Expand Up @@ -1015,6 +1024,7 @@ private void apply() {
this.obj_type_inherit_to_child_enabled = getBoolean("obj_type_inherit_to_child_enabled", false);
this.jmx_counter_enabled = getBoolean("jmx_counter_enabled", true);
this._profile_fullstack_sql_connection_enabled = getBoolean("_profile_fullstack_sql_connection_enabled", false);
this._profile_fullstack_sql_execute_debug_enabled = getBoolean("_profile_fullstack_sql_execute_debug_enabled", false);
this._trace_fullstack_socket_open_port = getInt("_trace_fullstack_socket_open_port", 0);
this._trace_sql_parameter_max_count = getInt("_trace_sql_parameter_max_count", 128);
this.log_dir = getValue("log_dir", "");
Expand Down Expand Up @@ -1054,6 +1064,7 @@ private void apply() {

this.xlog_discard_service_patterns = getValue("xlog_discard_service_patterns", "");
this.xlog_discard_service_show_error = getBoolean("xlog_discard_service_show_error", true);
this.xlog_fully_discard_service_patterns = getValue("xlog_fully_discard_service_patterns", "");

resetObjInfo();
setStaticContents();
Expand Down
18 changes: 18 additions & 0 deletions scouter.agent.java/src/main/java/scouter/agent/JavaAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,23 @@

import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Method;

import static scouter.agent.Logger.conf;

public class JavaAgent {
private static Instrumentation instrumentation;
private static boolean java9plus;
private static ClassLoader platformClassLoader;

static {
try
{
Method m = ClassLoader.class.getDeclaredMethod("getPlatformClassLoader", new Class[0]);
platformClassLoader = (ClassLoader) m.invoke(null, new Object[0]);
java9plus = true;
} catch (Exception ignored) {}
}

public static void premain(String options, Instrumentation instrum) {
preStart(options, instrum, new AgentTransformer());
Expand Down Expand Up @@ -123,4 +135,10 @@ private static String cut(String s) {
public static Instrumentation getInstrumentation() {
return instrumentation;
}
public static boolean isJava9plus() {
return java9plus;
}
public static ClassLoader getPlatformClassLoader() {
return platformClassLoader;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
package scouter.agent.asm;


import scouter.agent.ClassDesc;
import scouter.agent.Configure;
import scouter.agent.asm.util.HookingSet;
import scouter.agent.trace.TraceSQL;
import scouter.org.objectweb.asm.ClassVisitor;
import scouter.org.objectweb.asm.MethodVisitor;
import scouter.org.objectweb.asm.Opcodes;
import scouter.org.objectweb.asm.Type;
import scouter.org.objectweb.asm.commons.LocalVariablesSorter;
import scouter.agent.ClassDesc;
import scouter.agent.Configure;
import scouter.agent.asm.util.HookingSet;
import scouter.agent.trace.TraceMain;

import java.util.Set;

Expand Down Expand Up @@ -70,7 +70,7 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si

// ///////////////////////////////////////////////////////////////////////////
class InitialContextMV extends LocalVariablesSorter implements Opcodes {
private static final String CLASS = TraceMain.class.getName().replace('.', '/');
private static final String CLASS = TraceSQL.class.getName().replace('.', '/');
private static final String METHOD = "ctxLookup";
private static final String SIGNATURE = "(Ljava/lang/Object;Ljava/lang/Object;)V";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@

package scouter.agent.asm;

import scouter.org.objectweb.asm.*;
import scouter.org.objectweb.asm.commons.LocalVariablesSorter;
import scouter.agent.ClassDesc;
import scouter.agent.Configure;
import scouter.agent.asm.util.AsmUtil;
import scouter.agent.asm.util.HookingSet;
import scouter.agent.netio.data.DataProxy;
import scouter.agent.trace.TraceSQL;
import scouter.org.objectweb.asm.ClassVisitor;
import scouter.org.objectweb.asm.Label;
import scouter.org.objectweb.asm.MethodVisitor;
import scouter.org.objectweb.asm.Opcodes;
import scouter.org.objectweb.asm.Type;
import scouter.org.objectweb.asm.commons.LocalVariablesSorter;
import scouter.util.Pair;
import scouter.util.StringUtil;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -48,6 +51,7 @@ public JDBCConnectionOpenASM() {
AsmUtil.add(reserved, "org/apache/tomcat/dbcp/dbcp/BasicDataSource", "getConnection");
AsmUtil.add(reserved, "org/apache/tomcat/jdbc/pool/DataSourceProxy", "getConnection");
AsmUtil.add(reserved, "org/apache/commons/dbcp2/BasicDataSource", "getConnection");
AsmUtil.add(reserved, "com/zaxxer/hikari/HikariDataSource", "getConnection");

for(int i = JDBCTargetRegister.klassMethod.size() - 1; i >= 0; i--) {
AsmUtil.add(reserved, JDBCTargetRegister.klassMethod.get(i).getLeft(), JDBCTargetRegister.klassMethod.get(i).getRight());
Expand Down Expand Up @@ -93,7 +97,7 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
return mv;
}

String fullname = "OPEN " + StringUtil.cutLastString(className, '/') + "." + name;
String fullname = className.replace('/', '.') + "#" + name;
int fullname_hash = DataProxy.sendMethodName(fullname);

return new DbcOpenMV(access, desc, mv, fullname, fullname_hash);
Expand All @@ -106,7 +110,7 @@ class DbcOpenMV extends LocalVariablesSorter implements Opcodes {
private final static String START_METHOD = "dbcOpenStart";
private static final String START_SIGNATURE = "(ILjava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;";
private final static String END_METHOD = "dbcOpenEnd";
private static final String END_SIGNATURE = "(Ljava/sql/Connection;Ljava/lang/Object;)Ljava/sql/Connection;";
private static final String END_SIGNATURE = "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;";
private static final String END_SIGNATURE2 = "(Ljava/lang/Object;Ljava/lang/Throwable;)V";

private Label startFinally = new Label();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
class JDBCDriverMV extends LocalVariablesSorter implements Opcodes {
private static final String TRACE_SQL = TraceSQL.class.getName().replace('.', '/');
private final static String CONNECT_METHOD = "driverConnect";
private static final String CONNECT_SIGNATURE = "(Ljava/sql/Connection;Ljava/lang/String;)Ljava/sql/Connection;";
private static final String CONNECT_SIGNATURE = "(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;";

private static final String ERR_SIGNATURE = "(Ljava/lang/String;Ljava/lang/Throwable;)V";

private Label startFinally = new Label();
Expand Down
Loading

0 comments on commit 662ba46

Please sign in to comment.