{"action":"created","comment":{"url":"https://api.github.com/repos/heketi/heketi/pulls/comments/238219068","pull_request_review_id":180704381,"id":238219068,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODIxOTA2OA==","diff_hunk":"@@ -0,0 +1,48 @@\n+//\n+// Copyright (c) 2018 The heketi Authors\n+//\n+// This file is licensed to you under your choice of the GNU Lesser\n+// General Public License, version 3 or any later version (LGPLv3 or\n+// later), or the GNU General Public License, version 2 (GPLv2), in all\n+// cases as published by the Free Software Foundation.\n+\n+package profiling\n+\n+// Based on ideas from https://github.com/mistifyio/negroni-pprof\n+\n+import (\n+\t\"fmt\"\n+\t\"net/http\"\n+\t\"net/http/pprof\"\n+\t\"os\"\n+\truntime_pprof \"runtime/pprof\"\n+\n+\t\"github.com/gorilla/mux\"\n+)\n+\n+var (\n+\tbasePath string = \"/debug/pprof/\"\n+)\n+\n+func addPath(router *mux.Router, name string, handler http.Handler) {\n+\trouter.Path(basePath + name).Name(name).Handler(handler)\n+\tfmt.Fprintf(os.Stderr, \"DEBUG: registered profiling handler on %s\\n\", basePath+name)\n+}\n+\n+func EnableProfiling(router *mux.Router) {\n+\tfor _, profile := range runtime_pprof.Profiles() {\n+\t\tname := profile.Name()\n+\t\thandler := pprof.Handler(name)\n+\n+\t\taddPath(router, name, handler)\n+\t}\n+\n+\t// static profiles as listed in net/http/pprof/pprof.go:init()\n+\taddPath(router, \"cmdline\", http.HandlerFunc(pprof.Cmdline))\n+\taddPath(router, \"profile\", http.HandlerFunc(pprof.Profile))\n+\taddPath(router, \"symbol\", http.HandlerFunc(pprof.Symbol))\n+\taddPath(router, \"trace\", http.HandlerFunc(pprof.Trace))\n+\n+\t// The index handler only lists the runtime_pprof.Profiles(), so let's not index any.\n+\t//router.Methods(\"GET\").Path(basePath).Name(\"index\").Handler(http.HandlerFunc(pprof.Index))","path":"server/profiling/profiling.go","position":null,"original_position":47,"commit_id":"eba12bee7844218d493f0f0d2a9b322f38f07ac5","original_commit_id":"cf7d0ed849ceae4554a9753a0db5be36ce36603d","user":{"login":"nixpanic","id":400257,"node_id":"MDQ6VXNlcjQwMDI1Nw==","avatar_url":"https://avatars3.githubusercontent.com/u/400257?v=4","gravatar_id":"","url":"https://api.github.com/users/nixpanic","html_url":"https://github.com/nixpanic","followers_url":"https://api.github.com/users/nixpanic/followers","following_url":"https://api.github.com/users/nixpanic/following{/other_user}","gists_url":"https://api.github.com/users/nixpanic/gists{/gist_id}","starred_url":"https://api.github.com/users/nixpanic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nixpanic/subscriptions","organizations_url":"https://api.github.com/users/nixpanic/orgs","repos_url":"https://api.github.com/users/nixpanic/repos","events_url":"https://api.github.com/users/nixpanic/events{/privacy}","received_events_url":"https://api.github.com/users/nixpanic/received_events","type":"User","site_admin":false},"body":"ok, done!","created_at":"2018-12-03T10:44:39Z","updated_at":"2018-12-03T10:44:39Z","html_url":"https://github.com/heketi/heketi/pull/1396#discussion_r238219068","pull_request_url":"https://api.github.com/repos/heketi/heketi/pulls/1396","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/heketi/heketi/pulls/comments/238219068"},"html":{"href":"https://github.com/heketi/heketi/pull/1396#discussion_r238219068"},"pull_request":{"href":"https://api.github.com/repos/heketi/heketi/pulls/1396"}},"in_reply_to_id":237862269},"pull_request":{"url":"https://api.github.com/repos/heketi/heketi/pulls/1396","id":222101177,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyMTAxMTc3","html_url":"https://github.com/heketi/heketi/pull/1396","diff_url":"https://github.com/heketi/heketi/pull/1396.diff","patch_url":"https://github.com/heketi/heketi/pull/1396.patch","issue_url":"https://api.github.com/repos/heketi/heketi/issues/1396","number":1396,"state":"open","locked":false,"title":"heketi: add support for profiling with pprof","user":{"login":"nixpanic","id":400257,"node_id":"MDQ6VXNlcjQwMDI1Nw==","avatar_url":"https://avatars3.githubusercontent.com/u/400257?v=4","gravatar_id":"","url":"https://api.github.com/users/nixpanic","html_url":"https://github.com/nixpanic","followers_url":"https://api.github.com/users/nixpanic/followers","following_url":"https://api.github.com/users/nixpanic/following{/other_user}","gists_url":"https://api.github.com/users/nixpanic/gists{/gist_id}","starred_url":"https://api.github.com/users/nixpanic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nixpanic/subscriptions","organizations_url":"https://api.github.com/users/nixpanic/orgs","repos_url":"https://api.github.com/users/nixpanic/repos","events_url":"https://api.github.com/users/nixpanic/events{/privacy}","received_events_url":"https://api.github.com/users/nixpanic/received_events","type":"User","site_admin":false},"body":"### What does this PR achieve? Why do we need it?\r\n\r\nAdd support for profiling like \"net/http/pprof\" does, but through the\r\n\"gorilla/mux\" router. Profiling is disabled by default, set the\r\n`HEKETI_PROFILING` environment variable to a non-empty string or add\r\n`\"profiling\": true` to the --config file.\r\n\r\nSeveral endpoints will get registered, and are writter to stderr:\r\n\r\n    $ HEKETI_PROFILING=1 ./heketi --config=heketi.json\r\n    ...\r\n    DEBUG: registered profiling handler on /debug/pprof/block\r\n    DEBUG: registered profiling handler on /debug/pprof/goroutine\r\n    DEBUG: registered profiling handler on /debug/pprof/heap\r\n    DEBUG: registered profiling handler on /debug/pprof/mutex\r\n    DEBUG: registered profiling handler on /debug/pprof/threadcreate\r\n    DEBUG: registered profiling handler on /debug/pprof/cmdline\r\n    DEBUG: registered profiling handler on /debug/pprof/profile\r\n    DEBUG: registered profiling handler on /debug/pprof/symbol\r\n    DEBUG: registered profiling handler on /debug/pprof/trace\r\n    ...\r\n\r\nStandard tools like `go tool pprof` and `curl` work. Examples:\r\n\r\n    $ go tool pprof http://localhost:8080/debug/pprof/profile\r\n    $ go tool pprof http://localhost:8080/debug/pprof/heap\r\n    $ curl http://localhost:8080/debug/pprof/heap?debug=1\r\n\r\n\r\n### Does this PR fix issues?\r\n\r\nFixes #799\r\n\r\n### Notes for the reviewer\r\n\r\nhttps://golang.org/pkg/net/http/pprof/ contains more details about the pprof interface.\r\n","created_at":"2018-10-11T11:24:51Z","updated_at":"2018-12-03T10:44:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7369f811bfb05e5c19c615d3a83c2e88ccbacaf0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/heketi/heketi/pulls/1396/commits","review_comments_url":"https://api.github.com/repos/heketi/heketi/pulls/1396/comments","review_comment_url":"https://api.github.com/repos/heketi/heketi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/heketi/heketi/issues/1396/comments","statuses_url":"https://api.github.com/repos/heketi/heketi/statuses/eba12bee7844218d493f0f0d2a9b322f38f07ac5","head":{"label":"nixpanic:pr/pprof","ref":"pr/pprof","sha":"eba12bee7844218d493f0f0d2a9b322f38f07ac5","user":{"login":"nixpanic","id":400257,"node_id":"MDQ6VXNlcjQwMDI1Nw==","avatar_url":"https://avatars3.githubusercontent.com/u/400257?v=4","gravatar_id":"","url":"https://api.github.com/users/nixpanic","html_url":"https://github.com/nixpanic","followers_url":"https://api.github.com/users/nixpanic/followers","following_url":"https://api.github.com/users/nixpanic/following{/other_user}","gists_url":"https://api.github.com/users/nixpanic/gists{/gist_id}","starred_url":"https://api.github.com/users/nixpanic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nixpanic/subscriptions","organizations_url":"https://api.github.com/users/nixpanic/orgs","repos_url":"https://api.github.com/users/nixpanic/repos","events_url":"https://api.github.com/users/nixpanic/events{/privacy}","received_events_url":"https://api.github.com/users/nixpanic/received_events","type":"User","site_admin":false},"repo":{"id":61882111,"node_id":"MDEwOlJlcG9zaXRvcnk2MTg4MjExMQ==","name":"heketi","full_name":"nixpanic/heketi","private":false,"owner":{"login":"nixpanic","id":400257,"node_id":"MDQ6VXNlcjQwMDI1Nw==","avatar_url":"https://avatars3.githubusercontent.com/u/400257?v=4","gravatar_id":"","url":"https://api.github.com/users/nixpanic","html_url":"https://github.com/nixpanic","followers_url":"https://api.github.com/users/nixpanic/followers","following_url":"https://api.github.com/users/nixpanic/following{/other_user}","gists_url":"https://api.github.com/users/nixpanic/gists{/gist_id}","starred_url":"https://api.github.com/users/nixpanic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nixpanic/subscriptions","organizations_url":"https://api.github.com/users/nixpanic/orgs","repos_url":"https://api.github.com/users/nixpanic/repos","events_url":"https://api.github.com/users/nixpanic/events{/privacy}","received_events_url":"https://api.github.com/users/nixpanic/received_events","type":"User","site_admin":false},"html_url":"https://github.com/nixpanic/heketi","description":"RESTful based volume management framework for GlusterFS","fork":true,"url":"https://api.github.com/repos/nixpanic/heketi","forks_url":"https://api.github.com/repos/nixpanic/heketi/forks","keys_url":"https://api.github.com/repos/nixpanic/heketi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nixpanic/heketi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nixpanic/heketi/teams","hooks_url":"https://api.github.com/repos/nixpanic/heketi/hooks","issue_events_url":"https://api.github.com/repos/nixpanic/heketi/issues/events{/number}","events_url":"https://api.github.com/repos/nixpanic/heketi/events","assignees_url":"https://api.github.com/repos/nixpanic/heketi/assignees{/user}","branches_url":"https://api.github.com/repos/nixpanic/heketi/branches{/branch}","tags_url":"https://api.github.com/repos/nixpanic/heketi/tags","blobs_url":"https://api.github.com/repos/nixpanic/heketi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nixpanic/heketi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nixpanic/heketi/git/refs{/sha}","trees_url":"https://api.github.com/repos/nixpanic/heketi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nixpanic/heketi/statuses/{sha}","languages_url":"https://api.github.com/repos/nixpanic/heketi/languages","stargazers_url":"https://api.github.com/repos/nixpanic/heketi/stargazers","contributors_url":"https://api.github.com/repos/nixpanic/heketi/contributors","subscribers_url":"https://api.github.com/repos/nixpanic/heketi/subscribers","subscription_url":"https://api.github.com/repos/nixpanic/heketi/subscription","commits_url":"https://api.github.com/repos/nixpanic/heketi/commits{/sha}","git_commits_url":"https://api.github.com/repos/nixpanic/heketi/git/commits{/sha}","comments_url":"https://api.github.com/repos/nixpanic/heketi/comments{/number}","issue_comment_url":"https://api.github.com/repos/nixpanic/heketi/issues/comments{/number}","contents_url":"https://api.github.com/repos/nixpanic/heketi/contents/{+path}","compare_url":"https://api.github.com/repos/nixpanic/heketi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nixpanic/heketi/merges","archive_url":"https://api.github.com/repos/nixpanic/heketi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nixpanic/heketi/downloads","issues_url":"https://api.github.com/repos/nixpanic/heketi/issues{/number}","pulls_url":"https://api.github.com/repos/nixpanic/heketi/pulls{/number}","milestones_url":"https://api.github.com/repos/nixpanic/heketi/milestones{/number}","notifications_url":"https://api.github.com/repos/nixpanic/heketi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nixpanic/heketi/labels{/name}","releases_url":"https://api.github.com/repos/nixpanic/heketi/releases{/id}","deployments_url":"https://api.github.com/repos/nixpanic/heketi/deployments","created_at":"2016-06-24T12:12:13Z","updated_at":"2018-05-16T09:41:12Z","pushed_at":"2018-12-03T10:44:27Z","git_url":"git://github.com/nixpanic/heketi.git","ssh_url":"git@github.com:nixpanic/heketi.git","clone_url":"https://github.com/nixpanic/heketi.git","svn_url":"https://github.com/nixpanic/heketi","homepage":"","size":21261,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"heketi:master","ref":"master","sha":"506929ddefb0c1fc24fc920f272aeea034b89e18","user":{"login":"heketi","id":12890374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyODkwMzc0","avatar_url":"https://avatars0.githubusercontent.com/u/12890374?v=4","gravatar_id":"","url":"https://api.github.com/users/heketi","html_url":"https://github.com/heketi","followers_url":"https://api.github.com/users/heketi/followers","following_url":"https://api.github.com/users/heketi/following{/other_user}","gists_url":"https://api.github.com/users/heketi/gists{/gist_id}","starred_url":"https://api.github.com/users/heketi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heketi/subscriptions","organizations_url":"https://api.github.com/users/heketi/orgs","repos_url":"https://api.github.com/users/heketi/repos","events_url":"https://api.github.com/users/heketi/events{/privacy}","received_events_url":"https://api.github.com/users/heketi/received_events","type":"Organization","site_admin":false},"repo":{"id":37446835,"node_id":"MDEwOlJlcG9zaXRvcnkzNzQ0NjgzNQ==","name":"heketi","full_name":"heketi/heketi","private":false,"owner":{"login":"heketi","id":12890374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyODkwMzc0","avatar_url":"https://avatars0.githubusercontent.com/u/12890374?v=4","gravatar_id":"","url":"https://api.github.com/users/heketi","html_url":"https://github.com/heketi","followers_url":"https://api.github.com/users/heketi/followers","following_url":"https://api.github.com/users/heketi/following{/other_user}","gists_url":"https://api.github.com/users/heketi/gists{/gist_id}","starred_url":"https://api.github.com/users/heketi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heketi/subscriptions","organizations_url":"https://api.github.com/users/heketi/orgs","repos_url":"https://api.github.com/users/heketi/repos","events_url":"https://api.github.com/users/heketi/events{/privacy}","received_events_url":"https://api.github.com/users/heketi/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/heketi/heketi","description":"RESTful based volume management framework for GlusterFS","fork":false,"url":"https://api.github.com/repos/heketi/heketi","forks_url":"https://api.github.com/repos/heketi/heketi/forks","keys_url":"https://api.github.com/repos/heketi/heketi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heketi/heketi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heketi/heketi/teams","hooks_url":"https://api.github.com/repos/heketi/heketi/hooks","issue_events_url":"https://api.github.com/repos/heketi/heketi/issues/events{/number}","events_url":"https://api.github.com/repos/heketi/heketi/events","assignees_url":"https://api.github.com/repos/heketi/heketi/assignees{/user}","branches_url":"https://api.github.com/repos/heketi/heketi/branches{/branch}","tags_url":"https://api.github.com/repos/heketi/heketi/tags","blobs_url":"https://api.github.com/repos/heketi/heketi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heketi/heketi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heketi/heketi/git/refs{/sha}","trees_url":"https://api.github.com/repos/heketi/heketi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heketi/heketi/statuses/{sha}","languages_url":"https://api.github.com/repos/heketi/heketi/languages","stargazers_url":"https://api.github.com/repos/heketi/heketi/stargazers","contributors_url":"https://api.github.com/repos/heketi/heketi/contributors","subscribers_url":"https://api.github.com/repos/heketi/heketi/subscribers","subscription_url":"https://api.github.com/repos/heketi/heketi/subscription","commits_url":"https://api.github.com/repos/heketi/heketi/commits{/sha}","git_commits_url":"https://api.github.com/repos/heketi/heketi/git/commits{/sha}","comments_url":"https://api.github.com/repos/heketi/heketi/comments{/number}","issue_comment_url":"https://api.github.com/repos/heketi/heketi/issues/comments{/number}","contents_url":"https://api.github.com/repos/heketi/heketi/contents/{+path}","compare_url":"https://api.github.com/repos/heketi/heketi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heketi/heketi/merges","archive_url":"https://api.github.com/repos/heketi/heketi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heketi/heketi/downloads","issues_url":"https://api.github.com/repos/heketi/heketi/issues{/number}","pulls_url":"https://api.github.com/repos/heketi/heketi/pulls{/number}","milestones_url":"https://api.github.com/repos/heketi/heketi/milestones{/number}","notifications_url":"https://api.github.com/repos/heketi/heketi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heketi/heketi/labels{/name}","releases_url":"https://api.github.com/repos/heketi/heketi/releases{/id}","deployments_url":"https://api.github.com/repos/heketi/heketi/deployments","created_at":"2015-06-15T06:10:11Z","updated_at":"2018-11-29T19:33:34Z","pushed_at":"2018-12-03T10:44:29Z","git_url":"git://github.com/heketi/heketi.git","ssh_url":"git@github.com:heketi/heketi.git","clone_url":"https://github.com/heketi/heketi.git","svn_url":"https://github.com/heketi/heketi","homepage":"","size":20930,"stargazers_count":723,"watchers_count":723,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":229,"mirror_url":null,"archived":false,"open_issues_count":189,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":229,"open_issues":189,"watchers":723,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/heketi/heketi/pulls/1396"},"html":{"href":"https://github.com/heketi/heketi/pull/1396"},"issue":{"href":"https://api.github.com/repos/heketi/heketi/issues/1396"},"comments":{"href":"https://api.github.com/repos/heketi/heketi/issues/1396/comments"},"review_comments":{"href":"https://api.github.com/repos/heketi/heketi/pulls/1396/comments"},"review_comment":{"href":"https://api.github.com/repos/heketi/heketi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/heketi/heketi/pulls/1396/commits"},"statuses":{"href":"https://api.github.com/repos/heketi/heketi/statuses/eba12bee7844218d493f0f0d2a9b322f38f07ac5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"nixpanic"}}