Skip to content

Commit

Permalink
Merge pull request scouter-project#500 from scouter-project/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
gunlee01 authored Sep 28, 2018
2 parents 14c195c + 9efc08f commit f636b98
Show file tree
Hide file tree
Showing 105 changed files with 4,983 additions and 986 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
SCOUTER is an open source APM like new relic and appdynamics.
(APM means application performance monitoring or application performance management.)

- **Monitoring target (currently)**
- **Monitoring target (scouter agent)**
- Java application - Web applications (on Tomcat, JBoss, Resin...), Standalone java applications
- OS - Linux, Windows, Unix

- **Monitoring target (to-be : contributing welcome)**
- Redis, Apach HTTPD, nginX, Nodejs ...
- **Monitoring target (telegraf agent support)**
- Redis, nginX, apache httpd, haproxy, Kafka, MySQL, MongoDB, RabbitMQ, ElasticSearch, Kube, Mesos ...

![Screen](./scouter.document/img/main/dashboard-sample-1.png)

Expand All @@ -38,6 +38,7 @@ SCOUTER can help you.
- [Live demo](./scouter.document/main/Live-Demo.md)
- [How to analyze XLog View](./scouter.document/client/Reading-XLog.md)
- [Customizable alarm - Alert plugins guide](./scouter.document/main/Alert-Plugin-Guide.md)
- [Telegraf server feature](./scouter.document/main/Telegraf-Server.md)
- [Client screen help](./scouter.document/client/How-To-Use-Client.md)

## Download
Expand All @@ -63,8 +64,8 @@ SCOUTER can help you.
- **[aws-monitor](https://github.com/nices96/scouter-pulse-aws-monitor)** : gathering performance metrics of EC2, RDS, ELB from cloudwatch in AWS.

### 3rd-party UIs
- **scouter paper** : [scouter-paper](https://github.com/mindplates/scouter-paper)
![scouter-pater](./scouter.document/img/main/scouter-paper.png)
- **scouter paper** : [scouter-paper](https://mindplates.github.io/scouter-paper/)
![scouter-pater](https://mindplates.github.io/scouter-paper/img/img12.png)

### Plugins
- **Server plugin**
Expand Down
11 changes: 6 additions & 5 deletions README_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

오픈소스 APM인 Scouter는 JVM(WAS, Standalone application)을 사용하는 어플리케이션 및 OS 자원에 대한 모니터링 모니터링 기능을 제공한다.
- **APM** : Application performance montoring / application performance management
- 모니터링 대상 (현재)
- 모니터링 대상 (전용 agent)
- Java application - Web application (on Tomcat, JBoss, Resin ...), Standalone java application
- OS - LInux, Windows, Unix
- 모니터링 대상 (TOBE)
- Redis, Apach HTTPD, nginX, Nodejs...
- 모니터링 대상 (Telegraf agent)
- Redis, nginX, apache httpd, haproxy, Kafka, MySQL, MongoDB, RabbitMQ, ElasticSearch, Kube, Mesos ...


![Screen](./scouter.document/img/main/dashboard-sample-1.png)
Expand All @@ -37,6 +37,7 @@
- [Live demo 접속](./scouter.document/main/Live-Demo_kr.md)
- [XLog 로 분석하기](./scouter.document/client/Reading-XLog_kr.md)
- [사용자 정의 알람 스크립팅 - Alert plugins guide](./scouter.document/main/Alert-Plugin-Guide_kr.md)
- [Telegraf server feature](./scouter.document/main/Telegraf-Server_kr.md)
- [Client 화면 설명](./scouter.document/client/How-To-Use-Client_kr.md)

## Download
Expand All @@ -63,8 +64,8 @@
- **[aws-monitor](https://github.com/nices96/scouter-pulse-aws-monitor)** : AWS의 Cloudwatch에서 EC2/RDS/ELB의 성능 카운터 정보를 수집

### 3rd-party UIs
- **scouter paper** : [scouter-paper](https://github.com/mindplates/scouter-paper)
![scouter-pater](./scouter.document/img/main/scouter-paper.png)
- **scouter paper** : [scouter-paper](https://mindplates.github.io/scouter-paper/)
![scouter-pater](https://mindplates.github.io/scouter-paper/img/img12.png)

### Plugins
- **Server plugin**
Expand Down
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.9.1.SNAPSHOT</version>
<version>2.0.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.9.1.SNAPSHOT</version>
<version>2.0.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.9.1.SNAPSHOT</version>
<version>2.0.0</version>
</parent>

<artifactId>scouter-agent-host</artifactId>
Expand Down
2 changes: 1 addition & 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.9.1.SNAPSHOT</version>
<version>2.0.0</version>
</parent>

<artifactId>scouter-agent-java</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
package scouter.agent;

import scouter.agent.asm.AddFieldASM;
import scouter.agent.asm.ApiCallResponseObjectASM;
import scouter.agent.asm.ApicallASM;
import scouter.agent.asm.ApicallInfoASM;
import scouter.agent.asm.ApicallSpringHandleResponseASM;
import scouter.agent.asm.ApicallSpringHttpAccessorASM;
import scouter.agent.asm.CapArgsASM;
import scouter.agent.asm.CapReturnASM;
Expand Down Expand Up @@ -50,7 +52,8 @@
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.JedisCommandASM;
import scouter.agent.asm.redis.JedisProtocolASM;
import scouter.agent.asm.redis.RedisCacheKeyASM;
import scouter.agent.asm.redis.RedisKeyASM;
import scouter.agent.asm.util.AsmUtil;
Expand Down Expand Up @@ -102,7 +105,6 @@ 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());
Expand All @@ -121,15 +123,19 @@ public static void reload() {
temp.add(new MethodASM());
temp.add(new ApicallASM());
temp.add(new ApicallInfoASM());
temp.add(new ApiCallResponseObjectASM());
temp.add(new ApicallSpringHandleResponseASM());
temp.add(new ApicallSpringHttpAccessorASM());

temp.add(new SpringAsyncExecutionASM());
temp.add(new SpringAsyncExecutionAspectSupportDoSubmitASM());
temp.add(new CallRunnableASM());
temp.add(new ExecutorServiceASM());

temp.add(new JedisCommandASM());
temp.add(new RedisKeyASM());
temp.add(new RedisCacheKeyASM());
temp.add(new JedisConnectionASM());
temp.add(new JedisProtocolASM());

temp.add(new SpringReqMapASM());
temp.add(new HystrixCommandASM());
Expand Down
12 changes: 12 additions & 0 deletions scouter.agent.java/src/main/java/scouter/agent/Configure.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ public final static synchronized Configure getInstance() {
public String _trace_interservice_callee_header_key = "X-Scouter-Callee";
@ConfigDesc("")
public String _trace_interservice_caller_header_key = "X-Scouter-Caller";
@ConfigDesc("")
public String _trace_interservice_caller_obj_header_key = "X-Scouter-Caller-Obj";
@ConfigDesc("")
public String _trace_interservice_callee_obj_header_key = "X-Scouter-Callee-Obj";
@ConfigDesc("JSession key for user ID")
public String trace_user_session_key = "JSESSIONID";
@ConfigDesc("")
Expand Down Expand Up @@ -573,6 +577,8 @@ public final static synchronized Configure getInstance() {
@ConfigDesc("")
public boolean _hook_methods_enabled = true;
@ConfigDesc("")
public boolean _hook_apicall_enabled = true;
@ConfigDesc("")
public boolean _hook_socket_enabled = true;
@ConfigDesc("")
public boolean _hook_jsp_enabled = true;
Expand Down Expand Up @@ -616,6 +622,8 @@ public final static synchronized Configure getInstance() {
public String counter_object_registry_path = "/tmp/scouter";
@ConfigDesc("Activating custom jmx")
public boolean counter_custom_jmx_enabled = false;
@ConfigDesc("Activating interaction counter")
public boolean counter_interaction_enabled = false;

// SFA(Stack Frequency Analyzer)
@ConfigDesc("Activating period threaddump function")
Expand Down Expand Up @@ -937,6 +945,8 @@ private void apply() {
this._trace_interservice_gxid_header_key = getValue("_trace_interservice_gxid_header_key", "X-Scouter-Gxid");
this._trace_interservice_callee_header_key = getValue("_trace_interservice_callee_header_key", "X-Scouter-Callee");
this._trace_interservice_caller_header_key = getValue("_trace_interservice_caller_header_key", "X-Scouter-Caller");
this._trace_interservice_caller_obj_header_key = getValue("_trace_interservice_caller_obj_header_key", "X-Scouter-Caller-Obj");
this._trace_interservice_callee_obj_header_key = getValue("_trace_interservice_callee_obj_header_key", "X-Scouter-Callee-Obj");
this.profile_connection_open_fullstack_enabled = getBoolean("profile_connection_open_fullstack_enabled", false);
this.profile_connection_autocommit_status_enabled = getBoolean("profile_connection_autocommit_status_enabled", false);
this.trace_user_mode = getInt("trace_user_mode", 2);
Expand All @@ -950,6 +960,7 @@ private void apply() {
this._hook_dbconn_enabled = getBoolean("_hook_dbconn_enabled", true);
this._hook_cap_enabled = getBoolean("_hook_cap_enabled", true);
this._hook_methods_enabled = getBoolean("_hook_methods_enabled", true);
this._hook_apicall_enabled = getBoolean("_hook_apicall_enabled", true);
this._hook_socket_enabled = getBoolean("_hook_socket_enabled", true);
this._hook_jsp_enabled = getBoolean("_hook_jsp_enabled", true);
this._hook_async_enabled = getBoolean("_hook_async_enabled", true);
Expand All @@ -967,6 +978,7 @@ private void apply() {
this.counter_recentuser_valid_ms = getLong("counter_recentuser_valid_ms", DateUtil.MILLIS_PER_FIVE_MINUTE);
this.counter_object_registry_path = getValue("counter_object_registry_path", "/tmp/scouter");
this.counter_custom_jmx_enabled = getBoolean("counter_custom_jmx_enabled", false);
this.counter_interaction_enabled = getBoolean("counter_interaction_enabled", false);
this.custom_jmx_set = getStringSet("custom_jmx_set", "||");
this.sfa_dump_enabled = getBoolean("sfa_dump_enabled", false);
this.sfa_dump_interval_ms = getInt("sfa_dump_interval_ms", 10000);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright 2015 the original author or authors.
* @https://github.com/scouter-project/scouter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package scouter.agent.asm;

import scouter.agent.ClassDesc;
import scouter.agent.Configure;
import scouter.agent.trace.TraceApiCall;
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 java.util.HashSet;
import java.util.Set;

/**
* @author Gun Lee ([email protected]) on 2018. 3. 20.
*/
public class ApiCallResponseObjectASM implements IASM, Opcodes {
private Configure conf = Configure.getInstance();

private static Set<String> hookingClasses = new HashSet<String>();
static {
hookingClasses.add("org/apache/http/impl/execchain/HttpResponseProxy");
hookingClasses.add("org/apache/http/impl/client/CloseableHttpResponseProxy");
}
public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) {
if (conf._hook_apicall_enabled == false)
return cv;

if (hookingClasses.contains(className)) {
return new ApiCallResponseObjectCV(cv, className);
}

return cv;
}
}

class ApiCallResponseObjectCV extends ClassVisitor implements Opcodes {
String className;

public ApiCallResponseObjectCV(ClassVisitor cv, String className) {
super(ASM5, cv);
this.className = className;
}

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
if (mv == null) {
return null;
}
if ("<init>".equals(name) && desc.startsWith("(Lorg/apache/http/HttpResponse;")) {
return new ApiCallResponseObjectInitMV(className, access, name, desc, mv);
}

return mv;
}
}

class ApiCallResponseObjectInitMV extends LocalVariablesSorter implements Opcodes {
private static final String TRACE = TraceApiCall.class.getName().replace('.', '/');
private static final String END_METHOD = "setCalleeToCtxInHttpClientResponse";
private static final String END_SIGNATURE = "(Ljava/lang/Object;Ljava/lang/Object;)V";

private String className;
private String name;
private String desc;
private int statIdx;
private Type returnType;
private Label startFinally = new Label();

public ApiCallResponseObjectInitMV(String className, int access, String name, String desc, MethodVisitor mv) {
super(ASM5, access, desc, mv);
this.className = className;
this.name = name;
this.desc = desc;
this.returnType = Type.getReturnType(desc);
}

@Override
public void visitInsn(int opcode) {
if ((opcode >= IRETURN && opcode <= RETURN)) {
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACE, END_METHOD, END_SIGNATURE, false);
}
mv.visitInsn(opcode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public ApicallASM() {
AsmUtil.add(reserved, "sun/net/www/protocol/http/HttpURLConnection", "getInputStream()Ljava/io/InputStream;");
AsmUtil.add(reserved, "sun/net/www/protocol/http/HttpURLConnection", "connect()V");
AsmUtil.add(reserved, "org/apache/commons/httpclient/HttpClient", "executeMethod("
+ "Lorg/apache/commons/httpclient/HostConfiguration;" + "Lorg/apache/commons/httpclient/HttpMethod;"
+ "Lorg/apache/commons/httpclient/HostConfiguration;"
+ "Lorg/apache/commons/httpclient/HttpMethod;"
+ "Lorg/apache/commons/httpclient/HttpState;" + ")I");
AsmUtil.add(reserved, "org/apache/http/impl/client/InternalHttpClient", "doExecute");
AsmUtil.add(reserved, "sun/net/www/http/HttpClient", "parseHTTP");
AsmUtil.add(reserved, "org/apache/http/impl/client/AbstractHttpClient",//
"execute(Lorg/apache/http/HttpHost;" + "Lorg/apache/http/HttpRequest;"
"execute(Lorg/apache/http/HttpHost;"
+ "Lorg/apache/http/HttpRequest;"
+ "Lorg/apache/http/protocol/HttpContext;)Lorg/apache/http/HttpResponse;");
// JCO CLIENT 추가..
AsmUtil.add(reserved, "com/sap/mw/jco/JCO$Client", "execute(Ljava/lang/String;" + //
Expand Down Expand Up @@ -82,7 +84,7 @@ public ApicallASM() {
}

public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) {
if (Configure.getInstance()._hook_methods_enabled == false) {
if (Configure.getInstance()._hook_apicall_enabled == false) {
return cv;
}
HookingSet mset = reserved.get(className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ApicallInfoASM() {
// "io/reactivex/netty/protocol/http/client/HttpClientResponse", "*");
}
public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) {
if (Configure.getInstance()._hook_methods_enabled == false) {
if (Configure.getInstance()._hook_apicall_enabled == false) {
return cv;
}
HookingSet mset = reserved.get(className);
Expand Down
Loading

0 comments on commit f636b98

Please sign in to comment.