From 6dd3b8a6bf773507ba7d4f8b02ecd3953d5dc379 Mon Sep 17 00:00:00 2001 From: keisku Date: Sat, 13 Apr 2024 06:03:05 +0000 Subject: [PATCH 1/2] improve doc --- README.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a0024bb..e7d4e18 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,11 @@ `gmon` is a tool designed to monitor the creation and destruction of goroutines in a Go program, drawing inspiration from the presentation [Real World Debugging with eBPF](https://www.usenix.org/conference/srecon23apac/presentation/liang). -# Pre-requisites +![gopher-sketch-science-welding](https://github.com/egonelbre/gophers/blob/63b1f5a9f334f9e23735c6e09ac003479ffe5df5/sketch/science/welding.png?raw=true) -- Kernel version >= 6.2.0, as I didn't test it on older versions. -- amd64 (x86_64) architecture +# Prerequisites + +- amd64 (x86_64) # Usage @@ -25,7 +26,9 @@ Usage of gmon: Path to Go runtime/trace output ``` -## stdout +## Stdout + +`gmon` logs the creation of goroutines to stdout with stack traces. ```bash sudo gmon -path /path/to/executable @@ -37,7 +40,13 @@ time=2024-03-20T05:10:57.752Z level=INFO msg="goroutine is created" goroutine_id time=2024-03-20T05:10:57.752Z level=INFO msg="goroutine is created" goroutine_id=35 stack.0=runtime.newproc stack.1=runtime.systemstack stack.2=runtime.newproc stack.3=net/http.(*connReader).startBackgroundRead stack.4=net/http.(*conn).serve stack.5=net/http.(*Server).Serve.gowrap3 stack.6=runtime.goexit ``` -## GET /metrics +## OpenMetrics + +`gmon` exposes the following metrics in the [OpenMetrics](https://www.cncf.io/projects/openmetrics/) format on the `GET /metrics`. + +- `gmon_goroutine_creation` +- `gmon_goroutine_exit` +- `gmon_goroutine_uptime` ```bash curl -s http://localhost:5500/metrics @@ -70,7 +79,10 @@ gmon_goroutine_uptime_count{stack_0="runtime.goexit",stack_1="main.main.gowrap1" Follow [the Docker installation guide](https://docs.docker.com/engine/install/#supported-platforms) to build and run tests. ```bash +# Build and output the binary to ./bin ./gmon.sh build +# Build and install the binary to /usr/bin ./gmon.sh install +# Run tests ./gmon.sh test ``` From cf5e7cef90779bddfd46b38213369145fecc120b Mon Sep 17 00:00:00 2001 From: keisku Date: Sat, 13 Apr 2024 06:06:17 +0000 Subject: [PATCH 2/2] resize --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e7d4e18..2dd2270 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Goroutine MONitor (gmon) -`gmon` is a tool designed to monitor the creation and destruction of goroutines in a Go program, drawing inspiration from the presentation [Real World Debugging with eBPF](https://www.usenix.org/conference/srecon23apac/presentation/liang). + -![gopher-sketch-science-welding](https://github.com/egonelbre/gophers/blob/63b1f5a9f334f9e23735c6e09ac003479ffe5df5/sketch/science/welding.png?raw=true) +`gmon` is a tool designed to monitor the creation and destruction of goroutines in a Go program, drawing inspiration from the presentation [Real World Debugging with eBPF](https://www.usenix.org/conference/srecon23apac/presentation/liang). # Prerequisites