https://github.com/alibaba/jvm-sandbox-repeater/blob/master/docs/user-guide-cn.md

快速录制自己应用


step0 安装sandbox和插件到应用服务器


curl -s https://github.com/alibaba/jvm-sandbox-repeater/releases/download/v1.0.0/install-repeater.sh | sh


step1 修改repeater-config.json,启用拦截点和插件信息


根据需要修改repeater-config.json配置文件,具体配置含义参见:RepeaterConfig.java

repeater-config.json默认下载在~/.sandbox-module/cfg/repeater-config.json

本使用手册是单机方式使用,实际项目应用时,配置文件需要从服务端拉取,配置变更时服务端推送到对应模块,框架也提供了拉取和推送配置接口。

{
"degrade": false,
"exceptionThreshold": 1000,
"httpEntrancePatterns": [
"^/regress/.*$"
],
"javaEntranceBehaviors": [
],
"javaSubInvokeBehaviors": [
],
"pluginIdentities": [
"http",
"mybatis",
"ibatis",
"dubbo-provider",
"dubbo-consumer"
],
"repeatIdentities": [
"java",
"http"
],
"sampleRate": 10000,
"useTtl": true
}

2启动目标应用,以查看进程号

ao@ubuntu2004:~/Documents$ java -jar demo-helloworld.jar

. ____ _ __ _ _

/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \

( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \

\\/ ___)| |_)| | | | | || (_| | ) ) ) )

' |____| .__|_| |_|_| |_\__, | / / / /

=========|_|==============|___/=/_/_/_/

:: Spring Boot :: (v2.1.0.RELEASE)

查看当前的java 认为的pid

# 使用 jps 查找进程 ID
jps -l


step3 attach sandbox到目标进程


cd ~/sandbox/bin

假设目标JVM进程号为'2343'

./sandbox.sh -p 2343 -P 12580
如果控制台输出,则说明启动成功

                NAMESPACE : defaultVERSION : 1.2.1MODE : ATTACHSERVER_ADDR : 0.0.0.0SERVER_PORT : 12580UNSAFE_SUPPORT : ENABLESANDBOX_HOME : /Users/froggen/sandboxSYSTEM_MODULE_LIB : /Users/froggen/sandbox/moduleUSER_MODULE_LIB : ~/.sandbox-module;SYSTEM_PROVIDER_LIB : /Users/froggen/sandbox/providerEVENT_POOL_SUPPORT : DISABLE

2:step2 attach sandbox到目标进程,

./sandbox.sh -p 7641 -P 12581

java.lang.NoClassDefFoundError: com/sun/tools/attach/VirtualMachine

at com.alibaba.jvm.sandbox.core.CoreLauncher.attachAgent(CoreLauncher.java:59)

at com.alibaba.jvm.sandbox.core.CoreLauncher.<init>(CoreLauncher.java:20)

at com.alibaba.jvm.sandbox.core.CoreLauncher.main(CoreLauncher.java:43)

Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.VirtualMachine

at java.net.URLClassLoader.findClass(URLClassLoader.java:387)

at java.lang.ClassLoader.loadClass(ClassLoader.java:418)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)

at java.lang.ClassLoader.loadClass(ClassLoader.java:351)

... 3 more

sandbox load jvm failed : com.sun.tools.attach.VirtualMachine

attach JVM 7641 fail.

报错需要设置java homeexport JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64  # 替换为实际路径export PATH=$PATH:/usr/local/armtool/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin
export PATH=$PATH:/home/gao/imx_linux/arm_book/env_cmd
export PATH=$JAVA_HOME/bin:$PATH

关闭sanbox

查看日志

tail -200f ~/logs/sandbox/repeater/repeater.log
2025-07-15 14:46:18 INFO  initializing logback success. file=/home/gao/.sandbox-module/cfg/repeater-logback.xml;
2025-07-15 14:46:18 INFO  module on loaded,id=repeater,version=1.0.0,mode=AGENT
2025-07-15 14:46:18 INFO  onActive
2025-07-15 14:46:19 INFO  pull repeater config success,config={sampleRate=10000, plugin=[http, mybatis, ibatis, dubbo-provider, dubbo-consumer]}
2025-07-15 14:46:19 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:19 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:19 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:19 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:19 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:19 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:19 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:19 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:20 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:20 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:20 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:20 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:20 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:20 INFO  http required javax.servlet.http.HttpServlet class router,waiting for class loading
2025-07-15 14:46:20 INFO  using target class loader to load plugin,class=Routing{regexExpresses=[^javax.servlet..*], classLoader=org.springframework.boot.loader.LaunchedURLClassLoader@52af26ee}
2025-07-15 14:46:20 WARN  no valid classloader found in routing,routing=PluginClassRouting{targetClass='org.apache.dubbo.rpc.model.ApplicationModel', classPattern='^org.apache.dubbo..*', identity='dubbo', matcher=REPEATER, block=false}
2025-07-15 14:46:20 INFO  enable plugin ibatis success
2025-07-15 14:46:20 INFO  add watcher success,type=ibatis,watcherId=1000
2025-07-15 14:46:20 INFO  enable plugin dubbo-consumer success
2025-07-15 14:46:20 INFO  add watcher success,type=dubbo,watcherId=1002
2025-07-15 14:46:20 INFO  add watcher success,type=dubbo,watcherId=1004
2025-07-15 14:46:20 INFO  enable plugin dubbo-provider success
2025-07-15 14:46:20 INFO  add watcher success,type=dubbo,watcherId=1006
2025-07-15 14:46:20 INFO  add watcher success,type=dubbo,watcherId=1008
2025-07-15 14:46:20 INFO  enable plugin http success
2025-07-15 14:46:21 INFO  add watcher success,type=http,watcherId=1010
2025-07-15 14:46:21 INFO  enable plugin mybatis success
2025-07-15 14:46:21 INFO  add watcher success,type=mybatis,watcherId=1013
2025-07-15 14:46:21 INFO  register event bus success in repeat-register
2025-07-15 15:27:03 INFO  initializing logback success. file=/home/gao/.sandbox-module/cfg/repeater-logback.xml;
2025-07-15 15:27:03 INFO  module on loaded,id=repeater,version=1.0.0,mode=ATTACH
2025-07-15 15:27:03 INFO  onActive
2025-07-15 15:27:03 INFO  pull repeater config success,config={sampleRate=10000, plugin=[http, mybatis, ibatis, dubbo-provider, dubbo-consumer]}
2025-07-15 15:27:03 INFO  using target class loader to load plugin,class=Routing{regexExpresses=[^javax.servlet..*], classLoader=org.springframework.boot.loader.LaunchedURLClassLoader@238e0d81}
2025-07-15 15:27:03 WARN  no valid classloader found in routing,routing=PluginClassRouting{targetClass='org.apache.dubbo.rpc.model.ApplicationModel', classPattern='^org.apache.dubbo..*', identity='dubbo', matcher=REPEATER, block=false}
2025-07-15 15:27:03 INFO  enable plugin ibatis success
2025-07-15 15:27:03 INFO  add watcher success,type=ibatis,watcherId=1000
2025-07-15 15:27:03 INFO  enable plugin dubbo-consumer success
2025-07-15 15:27:04 INFO  add watcher success,type=dubbo,watcherId=1002
2025-07-15 15:27:04 INFO  add watcher success,type=dubbo,watcherId=1004
2025-07-15 15:27:04 INFO  enable plugin dubbo-provider success
2025-07-15 15:27:04 INFO  add watcher success,type=dubbo,watcherId=1006
2025-07-15 15:27:04 INFO  add watcher success,type=dubbo,watcherId=1008
2025-07-15 15:27:04 INFO  enable plugin http success
2025-07-15 15:27:04 INFO  add watcher success,type=http,watcherId=1010
2025-07-15 15:27:04 INFO  enable plugin mybatis success
2025-07-15 15:27:04 INFO  add watcher success,type=mybatis,watcherId=1013
2025-07-15 15:27:04 INFO  register event bus success in repeat-register

# 检查是否附加成功

curl -s "http://127.0.0.1:12581/sandbox/default/module/http/sandbox-module-mgr/list" | jq .

http://127.0.0.1:12581/sandbox/default/module/http/sandbox-module-mgr/list

网站输入这个地址

# 预期返回已加载模块列表

step3 开始录制?如何录制-没有成功收到录制数据

根据自己配置的协议,HTTP/Java/Dubbo进行请求录制,如录制成功在repeater.log会打出具体的TraceId,同时在~/.sandbox-module/repeater-data/record/文件中会写入TraceId关联的录制数据;

录制成功-生成文件

如果录制成功,是因为设置了规则,只录制带有

"^/regress/.*$",

而之前,官方例子,是带有regress 的

配置要监控的API的路径

再访问http://localhost:8080/demo/hello

http://127.0.0.1:8080/demo/hello?who=Alice

就能再日志看到

025-07-16 17:19:54 INFO broadcast success,traceId=127000001001175265759374910001ed,resp=success

2025-07-16 17:19:57 INFO broadcast success,traceId=127000001001175265759717110002ed,resp=success

2025-07-16 17:19:58 INFO broadcast success,traceId=127000001001175265759867410003ed,resp=success

回放验证:但是这个路径每次时间都变化

  1. bash复制下载

回放的路径和录制时候访问的路径一样

只不过最后加traceid

curl -s 'http://127.0.0.1:8080/demo/hello?Repeat-TraceId-X=127000001001175265759867410003ed'
Hello, World!gao@ubuntu2004:~$ curl -s 'http://127.0.0.1:8080/demo/hello?Repeat-TraceId-X=127000001001175265759867410003ed'
Hello, World!gao@ubuntu2004:~$ curl -s 'http://127.0.0.1:8080/demo/hello?Repeat-TraceId-X=127000001001175265759867410003ed'
Hello, World!gao@ubuntu2004:~$ 

2. 发送回放请求(关键!)

必须通过 HTTP Header 传递TraceId,而不是URL参数:

http://127.0.0.1:8080/demo/hello?who=Alice

curl -H "Repeat-TraceId-X: 127000001001175271587488610002ed" \
http://127.0.0.1:8080/demo/hello?who=Alice

回放指令

curl -H "Repeat-TraceId-X: 127000001001175271663843110001ed" http://127.0.0.1:8080/demo/hello?who=Alice

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/news/915153.shtml
繁体地址,请注明出处:http://hk.pswp.cn/news/915153.shtml
英文地址,请注明出处:http://en.pswp.cn/news/915153.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【C++底层剖析】++a vs a++:到底谁是左值,谁是右值?

在 C 编程中&#xff0c;我们经常使用 a 和 a 来实现自增操作。乍一看它们只是“先加还是后加”的语法糖&#xff0c;但你真的理解它们的底层机制、返回值类型和左值右值属性吗&#xff1f;1. a 和 a 的基础区别表达式名称语义返回值类型左值 / 右值a前置自增先将 a 加 1&#…

【世纪龙科技】汽车故障诊断与排除仿真教学软件让课堂更高效安全

随着汽车产业向智能化、电动化快速转型&#xff0c;职业院校汽修专业的教学模式正面临全新挑战。传统实车实训存在成本高、风险大、场景单一等问题&#xff0c;而行业对人才的要求却越来越高——既需要扎实的理论基础&#xff0c;又必须具备熟练的故障诊断能力。如何在保证安全…

网络基础9:按流负载均衡实验(等价路由)

实验eNS拓扑图&#xff1a;1. 网络拓扑与 IP 配置AR5&#xff1a;GE0/0/0: 192.168.1.1/24&#xff08;连接 AR6&#xff09;GE0/0/1: 192.168.3.1/24&#xff08;连接 AR8&#xff09;Loopback0: 1.1.1.1/32&#xff08;源地址&#xff09;AR6&#xff1a;GE0/0/0: 192.168.1.…

4G模块 A7680发送中文短信到手机

命令说明 基础AT指令 ATi显示产品的标志信息 ATCIMI查询IMSI ATCICCID从SIM卡读取ICCID ATCGSN查询产品序列号 ATCPIN查询卡状态 ATCSQ查询信号强度 ATCGATT查询当前PS域状态 ATCREG查询GPRS注册状态 ATCEREG查询4G注册状态 ATCGPADDR查询PDP地址 ATCMGF选择短信格式 ATCMGS发…

深度学习-线性神经网络

文章目录线性回归基本概念随机梯度下降矢量化加速正态分布和平方损失极大似然估计线性回归实现从0开始**torch.no_grad()的两种用途****为什么需要 l.sum().backward()&#xff1f;**调用现成库softmax回归图像数据集从0开始实现softmax利用框架API实现课程学习自李牧老师B站的…

【王树森推荐系统】推荐系统涨指标的方法04:多样性

涨指标的方法有哪些&#xff1f; 改进召回模型&#xff0c;添加新的召回模型改进粗排和精排模型提升召回&#xff0c;粗排&#xff0c;精排的多样性特殊对待新用户吗&#xff0c;低活用户等特殊人群利用关注&#xff0c;转发&#xff0c;评论这三种交互行为 排序的多样性 精排多…

1. Spring AI概述

一、前言 Spring AI 是由 Spring 团队推出的开源项目&#xff0c;旨在为 Java 开发者提供简洁、一致的 Spring 风格开发体验&#xff0c;用于构建基于生成式人工智能&#xff08;GenAI&#xff09;和大型语言模型&#xff08;LLM&#xff09;的应用程序。它通过标准化抽象层简…

[每日随题10] DP - 重链剖分 - 状压DP

整体概述 难度&#xff1a;1600 →\rightarrow→ 2200 →\rightarrow→ 2600 P6005 [USACO20JAN] Time is Mooney G 标签&#xff1a;DP 前置知识&#xff1a;链式前向星 难度&#xff1a;绿 1600 题目描述&#xff1a; 输入格式&#xff1a; 输出格式&#xff1a; 样例输…

【Ubuntu22.04】repo安装方法

背景 repo是Google开发的用于基于git管理Android版本库的一个工具&#xff0c;管理多个Git仓库的工具&#xff0c;它可以帮助您在一个代码库中管理多个Git仓库的代码。其在鸿蒙操作系统中大量使用。下面我们就介绍repo在wsl中的安装部署。 安装方法 使用中国科技大学资源 脚本i…

Vue3的definePros和defineEmits

在 Vue 3 中&#xff0c;defineProps 和 defineEmits 是组合式 API 中用于定义组件的 props 和 事件 的方法&#xff0c;提供了一种更简洁和明确的方式来管理组件的输入和输出。它们属于 Composition API 的一部分&#xff0c;在 Vue 2 中通常使用 props 和 $emit 来实现。1. d…

【华为机试】122. 买卖股票的最佳时机 II

文章目录122. 买卖股票的最佳时机 II描述示例 1示例 2示例 3提示解题思路核心观察关键洞察算法实现方法1&#xff1a;贪心算法&#xff08;推荐&#xff09;方法2&#xff1a;动态规划方法3&#xff1a;动态规划&#xff08;空间优化&#xff09;方法4&#xff1a;波峰波谷法算…

Spring MVC @RequestParam注解全解析

RequestParam 注解详解 RequestParam 是 Spring MVC 中最常用的注解之一&#xff0c;用于从 HTTP 请求中提取查询参数&#xff08;Query String&#xff09;或表单数据。它主要处理 application/x-www-form-urlencoded 类型的请求&#xff08;如 GET 请求或 POST 表单提交&…

从零掌握XML与DTD实体:原理、XXE漏洞攻防

本文仅用于技术研究&#xff0c;禁止用于非法用途。 Author:枷锁 文章目录一、XML基础1. 什么是XML&#xff1f;2. XML语法规则3. 数据类型二、DTD1. 认识DTD2. 声明DTD3. DTD实体4. 如何防御XXE攻击&#xff1f;5. 总结一、XML基础 1. 什么是XML&#xff1f; XML &#xff1…

.NET 8 Release Candidate 1 (RC1)现已发布,包括许多针对ASP.NET Core的重要改进!

.NET 8 Release Candidate 1 (RC1)发布&#xff1a;ASP.NET Core重大改进来袭&#xff01; 近日&#xff0c;.NET 8 Release Candidate 1 (RC1)正式发布&#xff0c;这是在今年晚些时候计划发布的最终 .NET 8 版本之前的两个候选版本中的第一个。此版本包含了大部分计划中的功…

Jenkins pipeline 部署docker通用模板

Jenkinsfile: Docker的NETWORK_NAME不要使用bridge默认网络&#xff0c;要使用自定义的网络如test默认 bridge 网络&#xff1a;容器间不能用名字互相访问&#xff0c;只能用 IP。自定义网络&#xff1a;容器间可以用名字互相访问&#xff0c;Docker 自动做了 DNS 解析。pipeli…

【每日算法】专题十五_BFS 解决 FloodFill 算法

1. 算法思想 Flood Fill 问题的核心需求 给定一个二维网格&#xff08;如像素矩阵&#xff09;、一个起始坐标 (x, y) 和目标颜色 newColor&#xff0c;要求&#xff1a; 将起始点 (x, y) 的颜色替换为 newColor。递归地将所有与起始点相邻&#xff08;上下左右&#xff09; …

ESLint 完整功能介绍和完整使用示例演示

以下是ESLint的完整功能介绍和完整使用示例演示&#xff1a; ESLint 完整功能介绍 一、核心功能静态代码分析&#xff1a; 通过解析JavaScript/TypeScript代码为抽象语法树&#xff08;AST&#xff09;&#xff0c;识别语法错误、潜在问题&#xff08;如未定义变量、未使用变量…

解决问题七大步骤

发现问题后寻找解决方案的流程可以细化为 7个核心步骤&#xff0c;每个步骤包含具体措施、信息源和关键技巧&#xff0c;形成“从自查到验证、从独立解决到寻求帮助”的完整闭环。以下是完善后的流程&#xff1a; 一、明确问题与初步自查&#xff08;前提&#xff1a;减少无效搜…

思维链(CoT)技术全景:原理、实现与前沿应用深度解析

一、核心概念与原理 定义与起源 CoT 是一种引导大语言模型&#xff08;LLM&#xff09;显式生成中间推理步骤的技术&#xff0c;通过模拟人类逐步解决问题的过程&#xff0c;提升复杂任务&#xff08;如数学证明、多步逻辑推理&#xff09;的准确性。该概念由 Google Brain 团…

实验-华为综合

华为综合实验 一 实验拓扑二 实验配置交换机2 vlan batch 10 20 int e0/0/2 port link-type access port default vlan 10 int e0/0/1 port link-type access port default vlan 20 int e0/0/3 port link-type trunk port trunk allow-pass vlan alltelnet交换机3 链路类型配置…