[TOC]java
安装
git clone https://github.com/alibaba/jvm-sandbox-repeater.git cd jvm-sandbox-repeater/bin ./bootstrap.sh
执行完成后应该会在用户根目录cd ~
生成一个 sandbox 目录,而且会启动一个 SpringBoot (Demo)应用(启动失败也无所谓,直接用本身的Java应用更方便)git
也能够直接执行curl -s http://sandbox-ecological.oss-cn-hangzhou.aliyuncs.com/install-repeater.sh | sh
仅安装 sandbox,不部署 Demo 应用github
配置
模板
{ "degrade": false, "exceptionThreshold": 1000, "httpEntrancePatterns": [ "^/regress/.*$" ], "javaEntranceBehaviors": [ { "classPattern": "com.alibaba.repeater.console.service.impl.RegressServiceImpl", "includeSubClasses": false, "methodPatterns": [ "getRegress" ] } ], "javaSubInvokeBehaviors": [ { "classPattern": "com.alibaba.repeater.console.service.impl.RegressServiceImpl", "includeSubClasses": false, "methodPatterns": [ "getRegressInner" ] }, { "classPattern": "com.alibaba.repeater.console.service.impl.RegressServiceImpl", "includeSubClasses": false, "methodPatterns": [ "findPartner" ] }, { "classPattern": "com.alibaba.repeater.console.service.impl.RegressServiceImpl", "includeSubClasses": false, "methodPatterns": [ "slogan" ] } ], "pluginIdentities": [ "http", "java-entrance", "java-subInvoke", "mybatis", "ibatis", "dubbo-provider", "dubbo-consumer" ], "repeatIdentities": [ "java", "http" ], "sampleRate": 10000, "useTtl": true }
说明
<style> table th:first-of-type { width: 150px; } </style>shell
配置项 | 释义 |
---|---|
useTtl | 是否开启ttl线程上下文切换,开启以后,才能将并发线程中发生的子调用记录下来,不然没法录制到并发子线程的子调用信息 |
degrade | 是否执行录制降级策略,开启以后,不进行录制,只处理回放请求 |
exceptionThreshold | 异常发生阈值;默认1000 |
sampleRate | 采样率;最小力度万分之一;默认值:10000 |
pluginsPath | 插件地址 |
httpEntrancePatterns | 因为HTTP接口的量太大(先后端未分离的状况可能还有静态资源)所以必须走白名单匹配模式才录制 |
javaEntranceBehaviors | java入口插件动态加强的行为 |
javaSubInvokeBehaviors | java子调用插件动态加强的行为 |
pluginIdentities | 须要启动的插件 |
repeatIdentities | 回放器插件 |
示例
该配置实现了对/perf
路径下接口的录制; mock了JPA中的两个mongo查询方法; cat ~/.sandbox-module/cfg/repeater-config.json
json
{ "degrade": false, "exceptionThreshold": 1000, "httpEntrancePatterns": [ "^/perf/.*$" ], "javaEntranceBehaviors": [ { "classPattern": "com.test.moudle.perf.service.PerfReportService", "includeSubClasses": true, "methodPatterns": [ "getReportDetail" ] } ], "javaSubInvokeBehaviors": [ { "classPattern": "com.test.moudle.perf.repository.PerfReportBaseRepository", "includeSubClasses": true, "methodPatterns": [ "findAllByReportId" ] }, { "classPattern": "com.test.moudle.perf.repository.PerfReportRepository", "includeSubClasses": true, "methodPatterns": [ "findById" ] } ], "pluginIdentities": [ "http", "java-entrance", "java-subInvoke" ], "repeatIdentities": [ "java", "http" ], "sampleRate": 10000, "useTtl": true }