-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add agent performance analysis * Application performance analysis, supporting the following features. - ThreadDump - DeadLockDetect - JavaFlameGraph - Metrics - JTop - VMFlags - HeapDump - JMapHisto - JHat * No more init performance analysis code inside the femas agent. * Resolving conflicts with develop branches
- Loading branch information
1 parent
99a2e2b
commit ace728b
Showing
79 changed files
with
7,217 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -402,4 +402,4 @@ private int findEndpointPort(EndpointSubset s, String serviceId, String primaryP | |
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...ent-core/src/main/java/com/tencent/tsf/femas/agent/classloader/JvmMonitorClassloader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright 2010-2021 the original author or authors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.tencent.tsf.femas.agent.classloader; | ||
|
||
|
||
import com.tencent.tsf.femas.agent.tools.Logger; | ||
|
||
import java.io.BufferedInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
|
||
public class JvmMonitorClassloader extends URLClassLoader { | ||
private static final Logger LOGGER = Logger.getLogger(JvmMonitorClassloader.class); | ||
// only enable at develop phase. | ||
private static final Boolean DUMP_LOADED_CLASSES = false; | ||
|
||
public JvmMonitorClassloader(URL[] urls) { | ||
super(urls); | ||
} | ||
|
||
@Override | ||
protected Class<?> findClass(String name) throws ClassNotFoundException { | ||
byte[] b = loadClassData(name); | ||
return defineClass(name, b, 0, b.length); | ||
} | ||
|
||
private byte[] loadClassData(String className) { | ||
if (DUMP_LOADED_CLASSES) { | ||
LOGGER.debug("load class: " + className.replace(".", "/") + ".class"); | ||
} | ||
// read class | ||
InputStream is = getClass().getClassLoader().getResourceAsStream( | ||
className.replace(".", "/") + ".class"); | ||
ByteArrayOutputStream byteSt = new ByteArrayOutputStream(); | ||
// write into byte | ||
int len = 0; | ||
try { | ||
while ((len = is.read()) != -1) { | ||
byteSt.write(len); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
// convert into byte array | ||
return byteSt.toByteArray(); | ||
} | ||
} |
Oops, something went wrong.