jvm-sandbox-repeater学习笔记 1


安装

git clone https://github.com/alibaba/jvm-sandbox-repeater.git
cd jvm-sandbox-repeater/bin
./bootstrap.sh

执行完成后应该会在用户根目录cd ~生成一个 sandbox 目录,并且会启动一个 SpringBoot (Demo)应用(启动失败也无所谓,直接用自己的Java应用更方便)

也可以直接执行curl -s http://sandbox-ecological.oss-cn-hangzhou.aliyuncs.com/install-repeater.sh | sh
仅安装 sandbox,不部署 Demo 应用

配置

模板

{
  "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
}

说明

配置项 释义
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

{
  "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
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM