Skip to content

Commit

Permalink
Merge pull request #853 from scouter-project/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
gunlee01 authored Mar 26, 2022
2 parents 018cfab + 6ccb929 commit 9543477
Show file tree
Hide file tree
Showing 71 changed files with 1,576 additions and 571 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ scouter.server.boot/database/*

scouter.document/.project

build_client_local.sh
build_package_local.sh


### Vim template
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ SCOUTER can help you.

- **Web API (Since @1.8.0)** : scouter web apis to get counters, XLogs, profiles and another performance metrics via HTTP protocol.
- [Web API Guide](./scouter.document/tech/Web-API-Guide.md)
- **Weaver (Since @2.17.0)** : Provides the ability to directly control Scouter XLog and Profiles at the code level of Java applications.
- [Scouter Weaver Guide](./scouter.document/weaver/Weaver-Guide.md)

### 3rd-party UIs
- **scouter paper** : [scouter paper homepage](https://scouter-contrib.github.io/scouter-paper/)
Expand Down
1 change: 1 addition & 0 deletions README_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

- **Web API (Since @1.8.0)** : 성능 카운터, XLog, 프로파일등의 정보를 HTTP 프로토콜을 통해 제공
- [Web API Guide](./scouter.document/tech/Web-API-Guide_kr.md)
- **Weaver (Since @2.17.0)** : Java 애플리케이션의 코드 수준에서 Scouter XLog와 Profile을 직접 제어하는 기능 제공

### 3rd-party UIs
- **scouter paper** : [scouter-paper homepage](https://scouter-contrib.github.io/scouter-paper/)
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>2.17.0-SNAPSHOT</version> <!--scouter-->
<version>2.17.1</version> <!--scouter-->
<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>2.17.0-SNAPSHOT</version> <!--scouter-->
<version>2.17.1</version> <!--scouter-->
</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>2.17.0-SNAPSHOT</version> <!--scouter-->
<version>2.17.1</version> <!--scouter-->
</parent>

<artifactId>scouter-agent-host</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions scouter.agent.host/src/main/java/scouter/agent/Configure.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ public StringKeyLinkedMap<ValueType> getConfigureValueType() {
}

private boolean isKube() {
Properties properties = System.getProperties();
return !StringUtil.isEmpty(properties.getProperty("KUBERNETES_SERVICE_HOST"));
Map<String, String> env = System.getenv();
return !StringUtil.isEmpty(env.get("KUBERNETES_SERVICE_HOST"));
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,49 @@ public void writeHostNameForKube(CounterBasket pw) {
File dir = new File(conf.counter_object_registry_path);
File file = new File(dir, seqNoForKube + ".scouterkubeseq");
if (dir.canWrite()) {
deleteAllHostNameFileWithIgnore(dir, seqNoForKube);
FileUtil.save(file, conf.obj_name.getBytes());
}

} else {
File dir = new File(conf.counter_object_registry_path);
if (dir == null)
return;

File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory())
continue;
String name = files[i].getName();
if (!name.endsWith(".scouterkubeseq")) {
continue;
}
if (files[i].canWrite()) {
files[i].delete();
}
deleteAllHostNameFileWithIgnore(dir, -1);
}
}

private void deleteAllHostNameFileWithIgnore(File dir, long ignoreSeq) {
if (dir == null)
return;

File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory())
continue;
String name = files[i].getName();
if (!name.endsWith(".scouterkubeseq")) {
continue;
}

int kubeSeq = cintErrorMinusOne(name.substring(0, name.lastIndexOf(".")));
if (kubeSeq < 0)
continue;
if (kubeSeq == ignoreSeq) {
continue;
}
if (files[i].canWrite()) {
files[i].delete();
}
}
}

public static int cintErrorMinusOne(String value) {
if (value == null) {
return -1;
} else {
try {
return Integer.parseInt(value);
} catch (Exception e) {
return -1;
}
}
}
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>2.17.0-SNAPSHOT</version> <!--scouter-->
<version>2.17.1</version> <!--scouter-->
</parent>

<artifactId>scouter-agent-java</artifactId>
Expand Down
15 changes: 13 additions & 2 deletions scouter.agent.java/src/main/java/scouter/agent/Configure.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ public static final Configure getInstance() {
@ConfigDesc("")
public int autodump_stuck_check_interval_ms = 10000;

@ConfigDesc("ends sxlog profile when it exceeds profile_force_end_stuck_millis.")
public boolean profile_force_end_stuck_service = true;
@ConfigDesc("alert when forcibly ends xlog profile.")
public boolean profile_force_end_stuck_alert = true;
@ConfigDesc("stuck service millis for forcibly ends xlog profile")
public int profile_force_end_stuck_millis = 300000;

//Auto dump options on exceeded process cpu
@ConfigDesc("Enable the function to generate dump file when this process cpu is over than the set threshold")
public boolean autodump_cpu_exceeded_enabled = false;
Expand Down Expand Up @@ -974,6 +981,10 @@ private void apply() {
this.autodump_stuck_thread_ms = getInt("autodump_stuck_thread_ms", 0);
this.autodump_stuck_check_interval_ms = getInt("autodump_stuck_check_interval_ms", 10000);

this.profile_force_end_stuck_service = getBoolean("profile_force_end_stuck_service", false);
this.profile_force_end_stuck_alert = getBoolean("profile_force_end_stuck_alert", true);
this.profile_force_end_stuck_millis = getInt("profile_force_end_stuck_millis", 300000);

this.autodump_cpu_exceeded_enabled = getBoolean("autodump_cpu_exceeded_enabled", false);
this.autodump_cpu_exceeded_threshold_pct = getInt("autodump_cpu_exceeded_threshold_pct", 90);
this.autodump_cpu_exceeded_duration_ms = getInt("autodump_cpu_exceeded_duration_ms", 30000);
Expand Down Expand Up @@ -1627,8 +1638,8 @@ public void initTmpDir() {
}

private boolean isKube() {
Properties properties = System.getProperties();
return !StringUtil.isEmpty(properties.getProperty("KUBERNETES_SERVICE_HOST"));
Map<String, String> env = System.getenv();
return !StringUtil.isEmpty(env.get("KUBERNETES_SERVICE_HOST"));
}

private String readHostNameFromHostAgent() {
Expand Down
4 changes: 2 additions & 2 deletions scouter.agent.java/src/main/java/scouter/agent/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private static String toString(Object message) {

private static String build(String id, String message) {
if (message == null) {
return "null-err-message";
message = "null-err-message";
}
return new StringBuffer(20 + id.length() + message.length())
.append(DateUtil.datetime(System.currentTimeMillis())).append(" [").append(id).append("] ")
Expand Down Expand Up @@ -254,4 +254,4 @@ public void close() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public JDBCPreparedStatementASM() {
noField.add("jdbc/FakePreparedStatement2");
noField.add("org/mariadb/jdbc/MariaDbClientPreparedStatement");
noField.add("org/mariadb/jdbc/MariaDbServerPreparedStatement");
target.add("com/mysql/cj/jdbc/ServerPreparedStatement");
noField.add("com/mysql/cj/jdbc/ServerPreparedStatement");
}

public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
public class WeaverClassASM implements IASM, Opcodes {

public static Set<String> weaveMethodNames = new HashSet<>();
public static Set<String> weaveMethodNames = new HashSet<String>();

@Override
public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

public class ReactiveSupportFactory {
private static final String REACTIVE_SUPPORT = "scouter.xtra.reactive.ReactiveSupport";
private static final String REACTIVE_SUPPORT_W_COROUTINE = "scouter.xtra.reactive.ReactiveSupportWithCoroutine";

public static final IReactiveSupport dummy = new IReactiveSupport() {
public Object subscriptOnContext(Object mono0, TraceContext traceContext) {
Expand All @@ -46,11 +47,20 @@ public static IReactiveSupport create(ClassLoader parent) {
if (loader == null) {
return dummy;
}
Class c = Class.forName(REACTIVE_SUPPORT, true, loader);
return (IReactiveSupport) c.newInstance();
IReactiveSupport reactiveSupport = null;
try {
Class c = Class.forName(REACTIVE_SUPPORT_W_COROUTINE, true, loader);
reactiveSupport = (IReactiveSupport) c.newInstance();
} catch (Throwable e) {
Logger.println("A133-0", "fail to create reactive support: REACTIVE_SUPPORT_W_COROUTINE", e);
Class c = Class.forName(REACTIVE_SUPPORT, true, loader);
reactiveSupport = (IReactiveSupport) c.newInstance();
Logger.println("success to create reactive support without coroutine support");
}
return reactiveSupport;

} catch (Throwable e) {
Logger.println("A133-1", "fail to create", e);
Logger.println("A133-2", "fail to create", e);
return dummy;
}
}
Expand Down
Loading

0 comments on commit 9543477

Please sign in to comment.