{"id":15282528,"url":"https://github.com/keisku/gmon","last_synced_at":"2025-07-08T10:11:39.778Z","repository":{"id":216094918,"uuid":"740461825","full_name":"keisku/gmon","owner":"keisku","description":"An eBPF tool monitoring a goroutine","archived":false,"fork":false,"pushed_at":"2024-09-16T00:57:10.000Z","size":1116,"stargazers_count":185,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T03:39:29.601Z","etag":null,"topics":["ebpf","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keisku.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-01-08T11:52:33.000Z","updated_at":"2025-04-30T07:27:33.000Z","dependencies_parsed_at":"2024-01-14T08:40:16.493Z","dependency_job_id":"271e0c16-1225-4d04-944b-24fd0fb13e43","html_url":"https://github.com/keisku/gmon","commit_stats":null,"previous_names":["keisku/gmon"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/keisku/gmon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keisku%2Fgmon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keisku%2Fgmon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keisku%2Fgmon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keisku%2Fgmon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keisku","download_url":"https://codeload.github.com/keisku/gmon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keisku%2Fgmon/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264248025,"owners_count":23579060,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ebpf","go","golang"],"created_at":"2024-09-30T14:26:43.210Z","updated_at":"2025-07-08T10:11:39.753Z","avatar_url":"https://github.com/keisku.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Goroutine MONitor (gmon)\n\n\u003cimg src=\"https://github.com/egonelbre/gophers/blob/63b1f5a9f334f9e23735c6e09ac003479ffe5df5/sketch/science/welding.png?raw=true\" width=\"200\" height=\"200\"\u003e\n\n`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).\n\n# Prerequisites\n\n- amd64 (x86_64)\n- Linux Kernel 5.8+ since `gmon` uses [BPF ring buffer](https://nakryiko.com/posts/bpf-ringbuf/)\n- Target Go binary must be compiled with Go 1.23+ since `gmon` uses fixed offset to get goroutine ID\n\n# Usage\n\n```\nUsage of gmon:\n  -level string\n    \tlog level could be one of [\"DEBUG\" \"INFO\" \"WARN\" \"ERROR\"] (default \"INFO\")\n  -metrics int\n    \tPort to be used for metrics server, /metrics endpoint (default 5500)\n  -path string\n    \tPath to executable file to be monitored (required)\n  -pid int\n    \tUseful when tracing programs that have many running instances\n  -pprof int\n    \tPort to be used for pprof server. If 0, pprof server is not started\n  -trace string\n    \tPath to Go runtime/trace output\n```\n\n## Demo\n\nhttps://github.com/keisku/gmon/assets/41987730/838fa12d-d622-4ad6-a9f0-6aab88acec55\n\n## Stdout\n\n`gmon` logs the creation of goroutines to stdout with stack traces.\n\n```bash\nsudo gmon -path /path/to/executable\ntime=2024-03-20T05:10:57.752Z level=INFO msg=\"goroutine is created\" goroutine_id=22 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\ntime=2024-03-20T05:10:57.752Z level=INFO msg=\"goroutine is created\" goroutine_id=21 stack.0=runtime.newproc stack.1=runtime.systemstack stack.2=runtime.newproc stack.3=net/http.(*Server).Serve stack.4=net/http.(*Server).ListenAndServe stack.5=main.main.gowrap1 stack.6=runtime.goexit\ntime=2024-03-20T05:10:57.752Z level=INFO msg=\"goroutine is created\" goroutine_id=23 stack.0=runtime.newproc stack.1=runtime.systemstack stack.2=runtime.newproc stack.3=net/http.(*Server).Serve stack.4=net/http.(*Server).ListenAndServe stack.5=main.main.gowrap1 stack.6=runtime.goexit\ntime=2024-03-20T05:10:57.752Z level=INFO msg=\"goroutine is created\" goroutine_id=34 stack.0=runtime.newproc stack.1=runtime.systemstack stack.2=runtime.newproc stack.3=net/http.(*Server).Serve stack.4=net/http.(*Server).ListenAndServe stack.5=main.main.gowrap1 stack.6=runtime.goexit\ntime=2024-03-20T05:10:57.752Z level=INFO msg=\"goroutine is created\" goroutine_id=24 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\ntime=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\n```\n\n## OpenMetrics\n\n`gmon` exposes the following metrics in the [OpenMetrics](https://www.cncf.io/projects/openmetrics/) format on the `GET /metrics`.\n\n- `gmon_goroutine_creation`\n- `gmon_goroutine_exit`\n- `gmon_goroutine_uptime`\n\n```bash\ncurl -s http://localhost:5500/metrics\n\n# HELP gmon_goroutine_creation The number of goroutines that have been creaated\n# TYPE gmon_goroutine_creation counter\ngmon_goroutine_creation{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\"} 1\ngmon_goroutine_creation{stack_0=\"runtime.goexit\",stack_1=\"net/http.(*Server).Serve.gowrap3\",stack_2=\"net/http.(*conn).serve\",stack_3=\"net/http.(*connReader).startBackgroundRead\",stack_4=\"runtime.newproc\"} 3\n# HELP gmon_goroutine_exit The number of goroutines that have been exited\n# TYPE gmon_goroutine_exit counter\ngmon_goroutine_exit{stack_0=\"runtime.goexit\",stack_1=\"net/http.(*Server).Serve.gowrap3\",stack_2=\"net/http.(*conn).serve\",stack_3=\"net/http.(*connReader).startBackgroundRead\",stack_4=\"runtime.newproc\"} 3\n# HELP gmon_goroutine_uptime Uptime of goroutines in seconds\n# TYPE gmon_goroutine_uptime histogram\ngmon_goroutine_uptime_bucket{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\",le=\"1\"} 2\ngmon_goroutine_uptime_bucket{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\",le=\"3\"} 2\ngmon_goroutine_uptime_bucket{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\",le=\"5\"} 2\ngmon_goroutine_uptime_bucket{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\",le=\"10\"} 2\ngmon_goroutine_uptime_bucket{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\",le=\"30\"} 2\ngmon_goroutine_uptime_bucket{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\",le=\"60\"} 2\ngmon_goroutine_uptime_bucket{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\",le=\"120\"} 2\ngmon_goroutine_uptime_bucket{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\",le=\"180\"} 2\ngmon_goroutine_uptime_bucket{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\",le=\"+Inf\"} 2\ngmon_goroutine_uptime_sum{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\"} 0.9001332019999999\ngmon_goroutine_uptime_count{stack_0=\"runtime.goexit\",stack_1=\"main.main.gowrap1\",stack_2=\"net/http.(*Server).ListenAndServe\",stack_3=\"net/http.(*Server).Serve\",stack_4=\"runtime.newproc\"} 2\n...skip...\n```\n\n# Development\n\nFollow [the Docker installation guide](https://docs.docker.com/engine/install/#supported-platforms) to build and run tests.\n\n```bash\n# Build and output the binary to ./bin\n./gmon.sh build\n# Build and install the binary to /usr/bin\n./gmon.sh install\n# Run tests\n./gmon.sh test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeisku%2Fgmon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeisku%2Fgmon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeisku%2Fgmon/lists"}