Skip to content

Commit

Permalink
feat!: remove GET method in /debug path (#5102)
Browse files Browse the repository at this point in the history
* featremove GET method in \/debug path

Signed-off-by: Ruihang Xia <[email protected]>

* update how-to document as well

Signed-off-by: Ruihang Xia <[email protected]>

---------

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Dec 5, 2024
1 parent 66c0445 commit cf0c84b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
6 changes: 3 additions & 3 deletions docs/how-to/how-to-profile-cpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## HTTP API
Sample at 99 Hertz, for 5 seconds, output report in [protobuf format](https://github.com/google/pprof/blob/master/proto/profile.proto).
```bash
curl -s '0:4000/debug/prof/cpu' > /tmp/pprof.out
curl -X POST -s '0:4000/debug/prof/cpu' > /tmp/pprof.out
```

Then you can use `pprof` command with the protobuf file.
Expand All @@ -13,10 +13,10 @@ go tool pprof -top /tmp/pprof.out

Sample at 99 Hertz, for 60 seconds, output report in flamegraph format.
```bash
curl -s '0:4000/debug/prof/cpu?seconds=60&output=flamegraph' > /tmp/pprof.svg
curl -X POST -s '0:4000/debug/prof/cpu?seconds=60&output=flamegraph' > /tmp/pprof.svg
```

Sample at 49 Hertz, for 10 seconds, output report in text format.
```bash
curl -s '0:4000/debug/prof/cpu?seconds=10&frequency=49&output=text' > /tmp/pprof.txt
curl -X POST -s '0:4000/debug/prof/cpu?seconds=10&frequency=49&output=text' > /tmp/pprof.txt
```
2 changes: 1 addition & 1 deletion docs/how-to/how-to-profile-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MALLOC_CONF=prof:true,lg_prof_interval:28 ./target/debug/greptime standalone sta
Dump memory profiling data through HTTP API:

```bash
curl localhost:4000/debug/prof/mem > greptime.hprof
curl -X POST localhost:4000/debug/prof/mem > greptime.hprof
```

You can periodically dump profiling data and compare them to find the delta memory usage.
Expand Down
16 changes: 3 additions & 13 deletions src/servers/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,22 +705,12 @@ impl HttpServer {
"/debug",
Router::new()
// handler for changing log level dynamically
.route(
"/log_level",
routing::get(dyn_log::dyn_log_handler).post(dyn_log::dyn_log_handler),
)
.route("/log_level", routing::post(dyn_log::dyn_log_handler))
.nest(
"/prof",
Router::new()
.route(
"/cpu",
routing::get(pprof::pprof_handler).post(pprof::pprof_handler),
)
.route(
"/mem",
routing::get(mem_prof::mem_prof_handler)
.post(mem_prof::mem_prof_handler),
),
.route("/cpu", routing::post(pprof::pprof_handler))
.route("/mem", routing::post(mem_prof::mem_prof_handler)),
),
)
}
Expand Down

0 comments on commit cf0c84b

Please sign in to comment.