跟踪http请求
通过观察DispatcherServlet的doService
方法实现
java
protected void doService(HttpServletRequest request, HttpServletResponse response) {
// 省略内部代码
}
1
2
3
2
3
bash
# 观察http请求url、耗时、响应状态码
[arthas@12048]$ watch org.springframework.web.servlet.DispatcherServlet doService 'params[0].getRequestUrl + " " + params[1].status'
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 35 ms, listenerId: 4
method=org.springframework.web.servlet.DispatcherServlet.doService location=AtExit
ts=2023-04-14 15:22:57; [cost=2.1445ms] result=@String[http://localhost:8080/file/fpga%E8%BE%93%E5%87%BA%E8%BE%93%E5%85%A5.json 304]
method=org.springframework.web.servlet.DispatcherServlet.doService location=AtExit
ts=2023-04-14 15:23:00; [cost=8.4231ms] result=@String[http://localhost:8080/file/fpga%E8%BE%93%E5%87%BA%E8%BE%93%E5%85%A5.json 200]
method=org.springframework.web.servlet.DispatcherServlet.doService location=AtExit
ts=2023-04-14 15:23:01; [cost=2.015ms] result=@String[http://localhost:8080/favicon.ico 404]
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10