{"id":19865783,"url":"https://github.com/DataDog/gostackparse","last_synced_at":"2025-05-02T05:32:02.779Z","repository":{"id":45087133,"uuid":"355511951","full_name":"DataDog/gostackparse","owner":"DataDog","description":"Package gostackparse parses goroutines stack traces as produced by panic() or debug.Stack() at ~300 MiB/s.","archived":false,"fork":false,"pushed_at":"2023-09-05T14:24:26.000Z","size":37,"stargazers_count":118,"open_issues_count":2,"forks_count":6,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-04T07:06:21.218Z","etag":null,"topics":["debugging","go","performance","stacktrace"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DataDog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2021-04-07T11:01:28.000Z","updated_at":"2025-03-01T17:52:41.000Z","dependencies_parsed_at":"2024-06-18T13:59:11.855Z","dependency_job_id":null,"html_url":"https://github.com/DataDog/gostackparse","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataDog%2Fgostackparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataDog%2Fgostackparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataDog%2Fgostackparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataDog%2Fgostackparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DataDog","download_url":"https://codeload.github.com/DataDog/gostackparse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251992993,"owners_count":21677022,"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":["debugging","go","performance","stacktrace"],"created_at":"2024-11-12T15:24:11.665Z","updated_at":"2025-05-02T05:31:58.441Z","avatar_url":"https://github.com/DataDog.png","language":"Go","readme":"[![ci test status](https://img.shields.io/github/workflow/status/DataDog/gostackparse/Go?label=tests)](https://github.com/DataDog/gostackparse/actions/workflows/go.yml?query=branch%3Amain)\n[![documentation](http://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/DataDog/gostackparse)\n\n# gostackparse\n\nPackage gostackparse parses goroutines stack traces as produced by [`panic()`](https://golang.org/pkg/builtin/#panic) or [`debug.Stack()`](https://golang.org/pkg/runtime/debug/#Stack) at ~300 MiB/s.\n\nParsing this data can be useful for [Goroutine Profiling](https://github.com/DataDog/go-profiler-notes/blob/main/goroutine.md#feature-matrix) or analyzing crashes from log files.\n\n## Usage\n\nThe package provides a simple [Parse()](https://pkg.go.dev/github.com/DataDog/gostackparse#Parse) API. You can use it like [this](./example):\n\n```go\nimport \"github.com/DataDog/gostackparse\"\n\nfunc main() {\n\t// Get a text-based stack trace\n\tstack := debug.Stack()\n\t// Parse it\n\tgoroutines, _ := gostackparse.Parse(bytes.NewReader(stack))\n\t// Ouptut the results\n\tjson.NewEncoder(os.Stdout).Encode(goroutines)\n}\n```\n\nThe result is a simple list of [Goroutine](https://pkg.go.dev/github.com/DataDog/gostackparse#Goroutine) structs:\n\n```\n[\n  {\n    \"ID\": 1,\n    \"State\": \"running\",\n    \"Wait\": 0,\n    \"LockedToThread\": false,\n    \"Stack\": [\n      {\n        \"Func\": \"runtime/debug.Stack\",\n        \"File\": \"/usr/local/Cellar/go/1.16/libexec/src/runtime/debug/stack.go\",\n        \"Line\": 24\n      },\n      {\n        \"Func\": \"main.main\",\n        \"File\": \"/home/go/src/github.com/DataDog/gostackparse/example/main.go\",\n        \"Line\": 18\n      }\n    ],\n    \"FramesElided\": false,\n    \"CreatedBy\": null\n  }\n]\n```\n\n## Design Goals\n\n1. Safe: No panics should be thrown.\n2. Simple: Keep this pkg small and easy to modify.\n3. Forgiving: Favor producing partial results over no results, even if the input data is different than expected.\n4. Efficient: Parse several hundred MiB/s.\n\n## Testing\n\ngostackparse has been tested using a combination of hand picked [test-fixtures](./test-fixtures), [property based testing](https://github.com/DataDog/gostackparse/search?q=TestParse_PropertyBased), and [fuzzing](https://github.com/DataDog/gostackparse/search?q=Fuzz).\n\n## Comparsion to panicparse\n\n[panicparse](https://github.com/maruel/panicparse) is a popular library implementing similar functionality.\n\ngostackparse was created to provide a subset of the functionality (only the parsing) using ~10x less code while achieving \u003e 100x faster performance. If you like fast minimalistic code, you might prefer it. If you're looking for more features and a larger community, use panicparse.\n\n## Benchmarks\n\ngostackparse includes a small benchmark that shows that it can parse [test-fixtures/waitsince.txt](./test-fixtures/waitsince.txt) at ~300 MiB/s and how that compares to panicparse.\n\n```\n$ cp panicparse_test.go.disabled panicparse_test.go\n$ go get -t .\n$ go test -bench .\ngoos: darwin\ngoarch: amd64\npkg: github.com/DataDog/gostackparse\ncpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\nBenchmarkGostackparse-12   45456    26275 ns/op 302.34 MiB/s   17243 B/op    306 allocs/op\nBenchmarkPanicparse-12     76    15943320 ns/op   0.50 MiB/s 5274247 B/op 116049 allocs/op\nPASS\nok  \tgithub.com/DataDog/gostackparse\t3.634s\n```\n\n## License\n\nThis work is dual-licensed under Apache 2.0 or BSD3. See [LICENSE](./LICENSE).\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDataDog%2Fgostackparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDataDog%2Fgostackparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDataDog%2Fgostackparse/lists"}