{"id":13811872,"url":"https://github.com/daangn/autopprof","last_synced_at":"2025-08-01T16:44:39.379Z","repository":{"id":62874017,"uuid":"553970941","full_name":"daangn/autopprof","owner":"daangn","description":"Automatically profile the Go applications when CPU or memory utilization crosses threshold","archived":false,"fork":false,"pushed_at":"2024-09-26T12:27:56.000Z","size":228,"stargazers_count":209,"open_issues_count":2,"forks_count":10,"subscribers_count":30,"default_branch":"main","last_synced_at":"2025-03-28T10:11:22.302Z","etag":null,"topics":[],"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/daangn.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}},"created_at":"2022-10-19T03:37:16.000Z","updated_at":"2025-03-21T14:44:26.000Z","dependencies_parsed_at":"2024-01-13T15:37:24.692Z","dependency_job_id":"b3aaae29-ac8e-4a35-b57a-372d456779ef","html_url":"https://github.com/daangn/autopprof","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":0.1578947368421053,"last_synced_commit":"be7f157b566478bc63474520431c827196d5170d"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daangn%2Fautopprof","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daangn%2Fautopprof/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daangn%2Fautopprof/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daangn%2Fautopprof/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daangn","download_url":"https://codeload.github.com/daangn/autopprof/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767239,"owners_count":20992548,"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":[],"created_at":"2024-08-04T04:00:37.390Z","updated_at":"2025-08-01T16:44:39.316Z","avatar_url":"https://github.com/daangn.png","language":"Go","readme":"# autopprof\n\n![Run tests](https://github.com/daangn/autopprof/workflows/Run%20tests/badge.svg) [![Release](https://img.shields.io/github/v/tag/daangn/autopprof?label=Release)](https://github.com/daangn/autopprof/releases)\n\nAutomatically profile the Go applications when CPU or memory utilization crosses specific\nthreshold levels against the Linux container CPU quota and memory limit.\n\nOnce you start the autopprof, the autopprof process will periodically check the CPU and\nmemory utilization of the Go applications. If the resource utilization crosses the\nspecified threshold for each type of resource, the autopprof will automatically profile\nthe application (heap or cpu) and report the profiling report to the specific reporter (\ne.g. Slack).\n\n| CPU Profile Report Example                                 | Memory Profile Report Example                              |\n|------------------------------------------------------------|------------------------------------------------------------|\n| ![profiling example cpu](images/profiling_example_cpu.png) | ![profiling example mem](images/profiling_example_mem.png) |\n\n## Installation\n\n```bash\ngo get -u github.com/daangn/autopprof\n```\n\n## Usage\n\n\u003e If your application is running on non-linux systems, you should check the\n\u003e ErrUnsupportedPlatform error returned from `autopprof.Start()` and handle it properly.\n\n```go\npackage main\n\nimport (\n\t\"errors\"\n\t\"log\"\n\n\t\"github.com/daangn/autopprof\"\n\t\"github.com/daangn/autopprof/report\"\n)\n\nfunc main() {\n\terr := autopprof.Start(autopprof.Option{\n\t\tCPUThreshold: 0.8, // Default: 0.75.\n\t\tMemThreshold: 0.8, // Default: 0.75.\n\t\tReporter: report.NewSlackReporter(\n\t\t\t\u0026report.SlackReporterOption{\n\t\t\t\tApp:       \"YOUR_APP_NAME\",\n\t\t\t\tToken:     \"YOUR_TOKEN_HERE\",\n\t\t\t\tChannelID: \"REPORT_CHANNEL_ID\",\n\t\t\t},\n\t\t),\n\t})\n\tif errors.Is(err, autopprof.ErrUnsupportedPlatform) {\n\t\t// You can just skip the autopprof.\n\t\tlog.Println(err)\n\t} else if err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tdefer autopprof.Stop()\n\n\t// Your code here.\n}\n```\n\n\u003e You can create a custom reporter by implementing the `report.Reporter` interface.\n\n## Benchmark\n\nBenchmark the overhead of watching the CPU and memory utilization. The overhead is very\nsmall, so we don't have to worry about the performance degradation.\n\n\u003e You can run the benchmark test with this command.\n\u003e\n\u003e ```bash\n\u003e ./benchmark.sh\n\u003e ```\n\u003e\n\n```\nBenchmarkLightJob-5                    \t49444164\t       245.6 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkLightJobWithWatchCPUUsage-5   \t48884026\t       250.1 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkLightJobWithWatchMemUsage-5   \t49036617\t       246.3 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkHeavyJob-5                    \t   59010\t      203759 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkHeavyJobWithWatchCPUUsage-5   \t   58915\t      204054 ns/op\t       2 B/op\t       0 allocs/op\nBenchmarkHeavyJobWithWatchMemUsage-5   \t   58850\t      204764 ns/op\t       2 B/op\t       0 allocs/op\n```\n\n## License\n\n[Apache 2.0](LICENSE)\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaangn%2Fautopprof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaangn%2Fautopprof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaangn%2Fautopprof/lists"}