Comments (4)
你这个可以试一下 打印header 头
你这个操作不对 , headers不是核心参数
watch org.springframework.web.servlet.DispatcherServlet doService '#httpRequest=params[0],#allHeaders={},#forEnumeration = :[#this.hasMoreElements()? (#headerName=#this.nextElement(),#allHeaders.add(#headerName+"="+#httpRequest.getHeader(#headerName)),#forEnumeration(#this)):null],#forEnumeration(#httpRequest.getHeaderNames()),#allHeaders' -n 5 -x 3
from arthas.
你好,感谢回复,有个疑问,这样写法是打印出所有方法的headers参数,但是我需要过滤指定方法的,有解决办法吗
from arthas.
也是可以解决的哈
第一步获取到request 对象
org.springframework.web.context.request.RequestContextHolder#getRequestAttributes
public static HttpServletRequest getRequest() {
ServletRequestAttributes servletRequestAttributes = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes());
return servletRequestAttributes.getRequest();
}
第二步 ognl 语法获取 request 对象
@org.springframework.web.context.request.RequestContextHolder@getRequestAttributes().getRequest()
第三步 整合之前的请求
这里只是做了一点点修改,request 不是从参数里面获取,从静态字段里面获取request对象
#httpRequest=@org.springframework.web.context.request.RequestContextHolder@getRequestAttributes().getRequest()
watch com.wangji92.arthas.plugin.demo.controller.CommonController userFastJson '#httpRequest=@org.springframework.web.context.request.RequestContextHolder@getRequestAttributes().getRequest(),#allHeaders={},#forEnumeration = :[#this.hasMoreElements()? (#headerName=#this.nextElement(),#allHeaders.add(#headerName+"="+#httpRequest.getHeader(#headerName)),#forEnumeration(#this)):null],#forEnumeration(#httpRequest.getHeaderNames()),{params,returnObj,throwExp,#allHeaders}' -v -n 5 -x 3 '1==1'
结果
[arthas@23956]$ watch com.wangji92.arthas.plugin.demo.controller.CommonController userFastJson '#[email protected] ntextHolder@getRequestAttributes().getRequest(),#allHeaders={},#forEnumeration = :[#this.hasMoreElements()? (#headerName=#this.nextElement(),#allHeaders.add(#h eaderName+"="+#httpRequest.getHeader(#headerName)),#forEnumeration(#this)):null],#forEnumeration(#httpRequest.getHeaderNames()),{params,returnObj,throwExp,#all Headers}' -v -n 5 -x 3 '1==1'
Press Q or Ctrl+C to abort.
Affect(class count: 2 , method count: 2) cost in 367 ms, listenerId: 4
Condition express: 1==1 , result: true
method=com.wangji92.arthas.plugin.demo.controller.CommonController.userFastJson location=AtExit
ts=2023-12-27 17:21:18; [cost=0.020101ms] result=@ArrayList[
@Object[][
@User[
name=@String[33],
age=@Long[0],
],
],
@User[
name=@String[33],
age=@Long[0],
],
null,
@ArrayList[
@String[content-type=application/json],
@String[content-length=30],
@String[host=localhost:8080],
@String[connection=Keep-Alive],
@String[user-agent=Apache-HttpClient/4.5.13 (Java/11.0.11)],
@String[accept-encoding=gzip,deflate],
],
]
from arthas.
#729 可以参考一下729 也可以过滤哦~ 这个过滤类信息
你也可以直接通过request 里面的uri 进行过滤 这样简单点 ,
org.springframework.web.servlet.DispatcherServlet doService 里面第一个参数 params[0] 获取路径 包含 xxx 作为条件表达式即可。
https://arthas.aliyun.com/doc/watch.html#%E6%9D%A1%E4%BB%B6%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%9A%84%E4%BE%8B%E5%AD%90
from arthas.
Related Issues (20)
- Arthas 3 和 4 版本分开发布
- profile start crash jvm
- 能否把 rpm 安装包加上呢?
- 物理机上安装arthas监控docker内的java进程,怎么处理?
- 动态编译的java源文件 引入的依赖(在项目中已经引入) 在本地调试是可以引入的 但是项目打成jar包后找不到需要的依赖
- vmtool error: ArthasJniLibraryxxxx.tmp no suitable image found
- 我已经指定了类加载器,还是报错java.lang.ClassNotFoundException
- 执行as.sh报错
- as.bat报错
- cpu 占用较高,但是占用 最高线程的threadID 为 -1 ,为 vm thread ,但是无法查看线程运行详情
- arthas使用netty的ByteBuf没有释放导致netty堆外内存泄漏
- 执行OGNL列表解析时,#this设置为了Advice而不是实际值
- k8s使用arthas-tunnel-server web页面连击agent无响应
- AsyncProfiler error: No such file or directory HOT 2
- vmtool 命令导致附加的进程崩溃
- Run in JDK17 fail: Unsupported class file major version 61 in 3.7.2 HOT 1
- jad命令,类文件太大
- Classloader中build tree时使用hashmap优化
- vmtool调用方法时如果多个参数问题 HOT 1
- 怎么通过单台机子下发命令,比如`tt`给所有集群中的机器,并收集结果
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arthas.