From c24c88d336929fe214691b450f9eb30864ebe8d5 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Mon, 8 Feb 2021 10:08:35 +0100 Subject: [PATCH] Add guide for pprof endpoints Signed-off-by: Hidde Beydals --- docs/dev-guides/debugging.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docs/dev-guides/debugging.md diff --git a/docs/dev-guides/debugging.md b/docs/dev-guides/debugging.md new file mode 100644 index 0000000000..fd070d4883 --- /dev/null +++ b/docs/dev-guides/debugging.md @@ -0,0 +1,35 @@ +# Advanced debugging + +This guide covers more advanced debugging topics such as collecting +runtime profiling data from GitOps Toolkit components. + +As a user, this page normally should be a last resort, but you may +be asked by a maintainer to share a [collected profile](#collecting-a-profile) +to debug e.g. performance issues. + +## Pprof + +The [GitOps Toolkit components](../components/index.md) serve [`pprof`](https://golang.org/pkg/net/http/pprof/) +runtime profiling data on their metrics HTTP server (default `:8080`). + +### Endpoints + +| | Path | +|-------------|------------------------| +| Index | `/debug/pprof/` | +| CPU profile | `/debug/pprof/profile` | +| Symbol | `/debug/pprof/symbol` | +| Trace | `/debug/pprof/trace` | + +### Collecting a profile + +To collect a profile, port-forward to the component's metrics endpoint and +collect the data from the [endpoint](#endpoints) of choice: + +```console +$ kubectl port-forward -n deploy/ 8080 +$ curl -Sk -v http://localhost:8080/debug/pprof/heap > heap.out +``` + +The collected profile [can be analyzed using `go`](https://blog.golang.org/pprof), +or shared with one of the maintainers.