jvm-sandbox-repeater學習筆記 1

[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.jsonjson

{
  "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
}
相關文章
相關標籤/搜索