GeezerVison is showing github.com — 1.For springboot, add EVENT BEFORE_BEAN_REGIST to perform bytecode re… · optimuse/uavstack@6ec5bca
File treeExpand file treeCollapse file tree Open diff view settings com.creditease.uav.hook.dubbo/src/main/java/com/creditease/uav/hook/dubbo com.creditease.uav.hook.httpclients/src/main/java/com/creditease/uav/hook com.creditease.uav.hook.jaxws/src/main/java/com/creditease/uav/hook/jaxws com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc com.creditease.uav.hook.mongoclients/src/main/java/com/creditease/uav/hook/mongoclients com.creditease.uav.hook.mq/src/main/java/com/creditease/uav/hook com.creditease.uav.hook.redis/src/main/java/com/creditease/uav/hook/redis com.creditease.uav.monitorframework.agent/src/main/java/com/creditease/uav/monitorframework/adaptors com.creditease.uav.monitorframework.dproxy/src/main/java/com/creditease/uav/monitorframework/webservice/listeners com.creditease.uav.monitorframework.springbootFat monitorframework/fat/dubbo uav/monitorframework/springbootFat
com.creditease.uav.monitorframework/src/main/java/com/creditease com.creditease.uav.tomcat.plus.core/src/main/java/com/creditease/tomcat/plus/interceptor
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.dubbo/src/main/java/com/creditease/uav/hook/dubbo/DubboHookProxy.java +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,6 +51,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 51 | 51 | Event evt = context.get(Event.class); | 52 | 52 |
| 53 | 53 | switch (evt) { | | 54 | + case SPRING_BEAN_REGIST: | 54 | 55 | case WEBCONTAINER_INIT: | 55 | 56 | InsertInterceptToClients(context, webapploader); | 56 | 57 | break; | @@ -69,6 +70,9 @@ public void start(HookContext context, ClassLoader webapploader) { | 69 | 70 |
| 70 | 71 | private void InsertInterceptToClients(HookContext context, ClassLoader webapploader) { | 71 | 72 |
| | 73 | + if (isHookEventDone("InsertInterceptToClients")) { | | 74 | + return; | | 75 | + } | 72 | 76 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 73 | 77 |
| 74 | 78 | String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | |
Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.httpclients/src/main/java/com/creditease/uav/hook/httpclients/async/HttpAsyncClientHookProxy.java +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -57,6 +57,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 57 | 57 | Event evt = context.get(Event.class); | 58 | 58 |
| 59 | 59 | switch (evt) { | | 60 | + case SPRING_BEAN_REGIST: | 60 | 61 | case WEBCONTAINER_INIT: | 61 | 62 | InsertInterceptToClients(context, webapploader); | 62 | 63 | break; | @@ -76,6 +77,10 @@ public void start(HookContext context, ClassLoader webapploader) { | 76 | 77 |
| 77 | 78 | public void InsertInterceptToClients(HookContext context, ClassLoader webapploader) { | 78 | 79 |
| | 80 | + if (isHookEventDone("InsertInterceptToClients")) { | | 81 | + return; | | 82 | + } | | 83 | + | 79 | 84 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 80 | 85 |
| 81 | 86 | String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | |
Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.httpclients/src/main/java/com/creditease/uav/hook/httpclients/sync/HttpClientHookProxy.java +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,6 +56,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 56 | 56 | Event evt = context.get(Event.class); | 57 | 57 |
| 58 | 58 | switch (evt) { | | 59 | + case SPRING_BEAN_REGIST: | 59 | 60 | case WEBCONTAINER_INIT: | 60 | 61 | InsertInterceptToClients(context, webapploader); | 61 | 62 | break; | @@ -76,6 +77,10 @@ public void start(HookContext context, ClassLoader webapploader) { | 76 | 77 |
| 77 | 78 | public void InsertInterceptToClients(HookContext context, ClassLoader webapploader) { | 78 | 79 |
| | 80 | + if (isHookEventDone("InsertInterceptToClients")) { | | 81 | + return; | | 82 | + } | | 83 | + | 79 | 84 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 80 | 85 |
| 81 | 86 | String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | |
Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.httpclients/src/main/java/com/creditease/uav/hook/httpclients3/sync/HttpClient3HookProxy.java +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,6 +56,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 56 | 56 | Event evt = context.get(Event.class); | 57 | 57 |
| 58 | 58 | switch (evt) { | | 59 | + case SPRING_BEAN_REGIST: | 59 | 60 | case WEBCONTAINER_RESOURCE_INIT: | 60 | 61 | break; | 61 | 62 | case WEBCONTAINER_INIT: | @@ -76,6 +77,10 @@ public void start(HookContext context, ClassLoader webapploader) { | 76 | 77 |
| 77 | 78 | public void InsertInterceptToClients(HookContext context, ClassLoader webapploader) { | 78 | 79 |
| | 80 | + if (isHookEventDone("InsertInterceptToClients")) { | | 81 | + return; | | 82 | + } | | 83 | + | 79 | 84 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 80 | 85 | String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | 81 | 86 | String basePath = (String) ic.get(InterceptConstants.BASEPATH); | |
Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.jaxws/src/main/java/com/creditease/uav/hook/jaxws/JaxWSHookProxy.java +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,6 +51,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 51 | 51 |
| 52 | 52 | Event event = context.get(Event.class); | 53 | 53 | switch (event) { | | 54 | + case SPRING_BEAN_REGIST: | 54 | 55 | case WEBCONTAINER_INIT: | 55 | 56 | insertIntercepter(context, webapploader); | 56 | 57 | break; | @@ -70,6 +71,10 @@ public void start(HookContext context, ClassLoader webapploader) { | 70 | 71 |
| 71 | 72 | private void insertIntercepter(HookContext context, ClassLoader webapploader) { | 72 | 73 |
| | 74 | + if (isHookEventDone("InsertInterceptToClients")) { | | 75 | + return; | | 76 | + } | | 77 | + | 73 | 78 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 74 | 79 |
| 75 | 80 | String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | @@ -87,7 +92,7 @@ public void doInstallDProxy(ClassLoader webapploader, final String appid) { | 87 | 92 | dpInstall.setTargetClassLoader(webapploader); | 88 | 93 |
| 89 | 94 | /** | 90 | | - * install proxy to InternalHttpAsyncClient | | 95 | + * install proxy to javax.xml.ws.Service | 91 | 96 | */ | 92 | 97 | dpInstall.installProxy("javax.xml.ws.Service", new String[] { "com.creditease.uav.hook.jaxws.interceptors" }, | 93 | 98 | new DynamicProxyProcessor() { | |
Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/JdbcHookProxy.java +7-26Lines changed: 7 additions & 26 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,17 +44,9 @@ public class JdbcHookProxy extends HookProxy { | 44 | 44 |
| 45 | 45 | private final DynamicProxyInstaller dpInstall; | 46 | 46 |
| 47 | | - private boolean isInjectDrvMgr = false; | 48 | | - private boolean isInjectDruid = false; | 49 | | - private boolean isInjectDBCP2 = false; | 50 | | - private boolean isInjectTomcatDBCP2 = false; | 51 | | - private boolean isInjectHikari = false; | 52 | | - private boolean isInjectDataSource = false; | 53 | | - | 54 | 47 | @SuppressWarnings("rawtypes") | 55 | 48 | public JdbcHookProxy(String id, Map config) { | 56 | 49 | super(id, config); | 57 | | - | 58 | 50 | dpInstall = new DynamicProxyInstaller(); | 59 | 51 | } | 60 | 52 |
| @@ -64,6 +56,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 64 | 56 | Event event = context.get(Event.class); | 65 | 57 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 66 | 58 | switch (event) { | | 59 | + case SPRING_BEAN_REGIST: | 67 | 60 | case WEBCONTAINER_RESOURCE_INIT: | 68 | 61 | this.injectDriverManager(webapploader, ic); | 69 | 62 | this.injectDBCP2(webapploader, ic); | @@ -113,12 +106,10 @@ private String getAppID(InterceptContext ic) { | 113 | 106 | */ | 114 | 107 | private void injectDriverManager(ClassLoader webapploader, InterceptContext ic) { | 115 | 108 |
| 116 | | - if (this.isInjectDrvMgr == true) { | | 109 | + if (isHookEventDone("isInjectDrvMgr")) { | 117 | 110 | return; | 118 | 111 | } | 119 | 112 |
| 120 | | - this.isInjectDrvMgr = true; | 121 | | - | 122 | 113 | JdbcDriverIT jdbcDriverIT = new JdbcDriverIT(this.getAppID(ic)); | 123 | 114 |
| 124 | 115 | jdbcDriverIT.initSomeDrivers(webapploader); | @@ -149,12 +140,10 @@ private void injectDataSource(InterceptContext ic) { | 149 | 140 | return; | 150 | 141 | } | 151 | 142 |
| 152 | | - if (this.isInjectDataSource == true) { | | 143 | + if (isHookEventDone("isInjectDataSource")) { | 153 | 144 | return; | 154 | 145 | } | 155 | 146 |
| 156 | | - this.isInjectDataSource = true; | 157 | | - | 158 | 147 | JdbcDriverIT jdbcDriverIT = new JdbcDriverIT(this.getAppID(ic)); | 159 | 148 |
| 160 | 149 | ServerVendor vendor = (ServerVendor) this.getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR); | @@ -188,12 +177,10 @@ private void injectTomcatDBCP2(ClassLoader webapploader, InterceptContext ic) { | 188 | 177 | return; | 189 | 178 | } | 190 | 179 |
| 191 | | - if (this.isInjectTomcatDBCP2 == true) { | | 180 | + if (isHookEventDone("isInjectTomcatDBCP2")) { | 192 | 181 | return; | 193 | 182 | } | 194 | 183 |
| 195 | | - this.isInjectTomcatDBCP2 = true; | 196 | | - | 197 | 184 | final String appid = this.getAppID(ic); | 198 | 185 |
| 199 | 186 | /** | @@ -242,12 +229,10 @@ private void injectDBCP2(ClassLoader webapploader, InterceptContext ic) { | 242 | 229 | return; | 243 | 230 | } | 244 | 231 |
| 245 | | - if (this.isInjectDBCP2 == true) { | | 232 | + if (isHookEventDone("isInjectDBCP2")) { | 246 | 233 | return; | 247 | 234 | } | 248 | 235 |
| 249 | | - this.isInjectDBCP2 = true; | 250 | | - | 251 | 236 | final String appid = this.getAppID(ic); | 252 | 237 |
| 253 | 238 | /** | @@ -294,12 +279,10 @@ private void injectHikari(ClassLoader webapploader, InterceptContext ic) { | 294 | 279 | return; | 295 | 280 | } | 296 | 281 |
| 297 | | - if (isInjectHikari == true) { | | 282 | + if (isHookEventDone("isInjectHikari")) { | 298 | 283 | return; | 299 | 284 | } | 300 | 285 |
| 301 | | - isInjectHikari = true; | 302 | | - | 303 | 286 | final String appid = this.getAppID(ic); | 304 | 287 |
| 305 | 288 | final String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | @@ -357,12 +340,10 @@ private void injectDruid(ClassLoader webapploader, InterceptContext ic) { | 357 | 340 | return; | 358 | 341 | } | 359 | 342 |
| 360 | | - if (this.isInjectDruid == true) { | | 343 | + if (isHookEventDone("isInjectDruid")) { | 361 | 344 | return; | 362 | 345 | } | 363 | 346 |
| 364 | | - this.isInjectDruid = true; | 365 | | - | 366 | 347 | final String appid = this.getAppID(ic); | 367 | 348 |
| 368 | 349 | /** | |
Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/AbsDBPoolHookProxy.java +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,6 +56,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 56 | 56 | Event event = context.get(Event.class); | 57 | 57 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 58 | 58 | switch (event) { | | 59 | + case SPRING_BEAN_REGIST: | 59 | 60 | case WEBCONTAINER_INIT: | 60 | 61 | initHook(ic); | 61 | 62 | break; | @@ -89,6 +90,9 @@ public void start(HookContext context, ClassLoader webapploader) { | 89 | 90 | */ | 90 | 91 | private void initHook(InterceptContext ic) { | 91 | 92 |
| | 93 | + if (isHookEventDone("initHook")) { | | 94 | + return; | | 95 | + } | 92 | 96 | String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | 93 | 97 | String basePath = (String) ic.get(InterceptConstants.BASEPATH); | 94 | 98 | appid = MonitorServerUtil.getApplicationId(contextPath, basePath); | |
Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/dbcp/DBCPHookProxy.java +5-7Lines changed: 5 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,8 +46,6 @@ public class DBCPHookProxy extends AbsDBPoolHookProxy { | 46 | 46 |
| 47 | 47 | protected DynamicProxyInstaller dpInstall; | 48 | 48 |
| 49 | | - private boolean isInit = false; | 50 | | - | 51 | 49 | @SuppressWarnings("rawtypes") | 52 | 50 | public DBCPHookProxy(String id, Map config) { | 53 | 51 | super(id, config); | @@ -62,6 +60,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 62 | 60 |
| 63 | 61 | Event event = context.get(Event.class); | 64 | 62 | switch (event) { | | 63 | + case SPRING_BEAN_REGIST: | 65 | 64 | case WEBCONTAINER_RESOURCE_INIT: | 66 | 65 | case WEBCONTAINER_INIT: | 67 | 66 | InsertInterceptToClients(context, webapploader); | @@ -93,16 +92,15 @@ public void start(HookContext context, ClassLoader webapploader) { | 93 | 92 | */ | 94 | 93 | private void InsertInterceptToClients(HookContext context, ClassLoader webapploader) { | 95 | 94 |
| | 95 | + if (isHookEventDone("InsertInterceptToClients")) { | | 96 | + return; | | 97 | + } | | 98 | + | 96 | 99 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 97 | 100 | String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | 98 | 101 | String basePath = (String) ic.get(InterceptConstants.BASEPATH); | 99 | 102 | appid = MonitorServerUtil.getApplicationId(contextPath, basePath); | 100 | 103 |
| 101 | | - if (isInit == true) { | 102 | | - return; | 103 | | - } | 104 | | - | 105 | | - isInit = true; | 106 | 104 | /** | 107 | 105 | * set the webapploader is the target classloader | 108 | 106 | */ | |
Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/hikari/HikariHookProxy.java +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -58,6 +58,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 58 | 58 |
| 59 | 59 | Event event = context.get(Event.class); | 60 | 60 | switch (event) { | | 61 | + case SPRING_BEAN_REGIST: | 61 | 62 | case WEBCONTAINER_RESOURCE_INIT: | 62 | 63 | case WEBCONTAINER_INIT: | 63 | 64 | InsertInterceptToClients(context, webapploader); | @@ -89,16 +90,15 @@ public void start(HookContext context, ClassLoader webapploader) { | 89 | 90 | */ | 90 | 91 | private void InsertInterceptToClients(HookContext context, ClassLoader webapploader) { | 91 | 92 |
| | 93 | + if (isHookEventDone("InsertInterceptToClients")) { | | 94 | + return; | | 95 | + } | | 96 | + | 92 | 97 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 93 | 98 | String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | 94 | 99 | String basePath = (String) ic.get(InterceptConstants.BASEPATH); | 95 | 100 | appid = MonitorServerUtil.getApplicationId(contextPath, basePath); | 96 | 101 |
| 97 | | - if (isInit == true) { | 98 | | - return; | 99 | | - } | 100 | | - | 101 | | - isInit = true; | 102 | 102 | // /** | 103 | 103 | // * set the webapploader is the target classloader | 104 | 104 | // */ | |
Collapse file Copy file name to clipboardExpand all lines: com.creditease.uav.hook.jdbc/src/main/java/com/creditease/uav/hook/jdbc/pools/mybatis/MybatisHookProxy.java +6-8Lines changed: 6 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,7 +49,6 @@ public class MybatisHookProxy extends AbsDBPoolHookProxy { | 49 | 49 | protected DynamicProxyInstaller dpInstall; | 50 | 50 |
| 51 | 51 | private ClassLoader webapploaderForMybatis = null; | 52 | | - private boolean isInit = false; | 53 | 52 |
| 54 | 53 | @SuppressWarnings("rawtypes") | 55 | 54 | public MybatisHookProxy(String id, Map config) { | @@ -65,6 +64,7 @@ public void start(HookContext context, ClassLoader webapploader) { | 65 | 64 | webapploaderForMybatis = webapploader; | 66 | 65 | Event event = context.get(Event.class); | 67 | 66 | switch (event) { | | 67 | + case SPRING_BEAN_REGIST: | 68 | 68 | case WEBCONTAINER_RESOURCE_INIT: | 69 | 69 | case WEBCONTAINER_INIT: | 70 | 70 | InsertInterceptToClients(context, webapploader); | @@ -111,17 +111,15 @@ protected void collectDBPoolMetrics(MonitorElement clientElem) { | 111 | 111 |
| 112 | 112 | private void InsertInterceptToClients(HookContext context, ClassLoader webapploader) { | 113 | 113 |
| | 114 | + if (isHookEventDone("InsertInterceptToClients")) { | | 115 | + return; | | 116 | + } | | 117 | + | 114 | 118 | InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); | 115 | 119 | String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH); | 116 | 120 | String basePath = (String) ic.get(InterceptConstants.BASEPATH); | 117 | 121 | appid = MonitorServerUtil.getApplicationId(contextPath, basePath); | 118 | 122 |
| 119 | | - if (isInit == true) { | 120 | | - return; | 121 | | - } | 122 | | - | 123 | | - isInit = true; | 124 | | - | 125 | 123 | dpInstall.setTargetClassLoader(webapploader); | 126 | 124 |
| 127 | 125 | dpInstall.installProxy("org.apache.ibatis.datasource.pooled.PooledDataSource", | @@ -157,7 +155,7 @@ private void collectDataSourceStat(MonitorElementInstance inst, DataSource pds, | 157 | 155 | ReflectHelper.invoke(className, pds, prefix + collectMtrx[i], null, null, webapploader)); | 158 | 156 | } | 159 | 157 |
| 160 | | - Object poolState = ReflectHelper.invoke(className, pds, "getPoolState", null, null,webapploader); | | 158 | + Object poolState = ReflectHelper.invoke(className, pds, "getPoolState", null, null, webapploader); | 161 | 159 |
| 162 | 160 | for (; i < collectMtrx.length; i++) { | 163 | 161 |
| |
|