{"action":"created","comment":{"url":"https://api.github.com/repos/square/p2/pulls/comments/78657226","id":78657226,"diff_hunk":"@@ -35,35 +38,59 @@ func WatchPrefix(\n \tif pause < 250*time.Millisecond {\n \t\tpause = 250 * time.Millisecond\n \t}\n+\n+\tlistLatencyHistogram, consulLatencyHistogram, outputPairsBlocking, outputPairsHistogram := watchHistograms(\"prefix\")\n+\n+\tvar (\n+\t\tsafeListStart    time.Time\n+\t\toutputPairsStart time.Time\n+\t)\n \tfor {\n \t\tselect {\n \t\tcase <-done:\n \t\t\treturn\n \t\tcase <-timer.C:\n \t\t}\n-\t\ttimer.Reset(pause) // upper bound on request rate\n+\t\tsafeListStart = time.Now()\n \t\tpairs, queryMeta, err := SafeList(clientKV, done, prefix, &api.QueryOptions{\n \t\t\tWaitIndex: currentIndex,\n \t\t})\n+\t\tlistLatencyHistogram.Update(int64(time.Since(safeListStart) / time.Millisecond))\n+\t\tif queryMeta != nil {\n+\t\t\tconsulLatencyHistogram.Update(int64(queryMeta.RequestTime))\n+\t\t}\n+\t\ttimer.Reset(pause)\n \t\tswitch err {\n \t\tcase CanceledError:\n \t\t\treturn\n \t\tcase nil:\n \t\t\tcurrentIndex = queryMeta.LastIndex\n+\t\t\toutputPairsStart = time.Now()\n \t\t\tselect {\n \t\t\tcase <-done:\n \t\t\tcase outPairs <- pairs:\n \t\t\t}\n+\t\t\toutputPairsBlocking.Update(int64(time.Since(outputPairsStart) / time.Millisecond))\n+\t\t\toutputPairsHistogram.Update(int64(unsafe.Sizeof(pairs)))\n \t\tdefault:\n \t\t\tselect {\n \t\t\tcase <-done:\n \t\t\tcase outErrors <- err:\n+\t\t\t\ttimer.Reset(2*time.Second + pause)\n \t\t\t}\n-\t\t\ttimer.Reset(2*time.Second + pause) // backoff\n \t\t}\n \t}\n }\n \n+func watchHistograms(watchType string) (listLatency metrics.Histogram, consulLatency metrics.Histogram, outputPairsWait metrics.Histogram, outputPairsBytes metrics.Histogram) {","path":"pkg/kp/consulutil/watch.go","position":64,"original_position":62,"commit_id":"8d37dc492bd5c4586fedf6253d41b064aef786ff","original_commit_id":"ac711d05bf88428a6ea606faadd0c8b461f8c028","user":{"login":"petertseng","id":346181,"avatar_url":"https://avatars.githubusercontent.com/u/346181?v=3","gravatar_id":"","url":"https://api.github.com/users/petertseng","html_url":"https://github.com/petertseng","followers_url":"https://api.github.com/users/petertseng/followers","following_url":"https://api.github.com/users/petertseng/following{/other_user}","gists_url":"https://api.github.com/users/petertseng/gists{/gist_id}","starred_url":"https://api.github.com/users/petertseng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petertseng/subscriptions","organizations_url":"https://api.github.com/users/petertseng/orgs","repos_url":"https://api.github.com/users/petertseng/repos","events_url":"https://api.github.com/users/petertseng/events{/privacy}","received_events_url":"https://api.github.com/users/petertseng/received_events","type":"User","site_admin":false},"body":"I don't see `watchType` being used in this function - should it be?","created_at":"2016-09-13T22:32:04Z","updated_at":"2016-09-13T22:32:04Z","html_url":"https://github.com/square/p2/pull/650#discussion_r78657226","pull_request_url":"https://api.github.com/repos/square/p2/pulls/650","_links":{"self":{"href":"https://api.github.com/repos/square/p2/pulls/comments/78657226"},"html":{"href":"https://github.com/square/p2/pull/650#discussion_r78657226"},"pull_request":{"href":"https://api.github.com/repos/square/p2/pulls/650"}}},"pull_request":{"url":"https://api.github.com/repos/square/p2/pulls/650","id":85119321,"html_url":"https://github.com/square/p2/pull/650","diff_url":"https://github.com/square/p2/pull/650.diff","patch_url":"https://github.com/square/p2/pull/650.patch","issue_url":"https://api.github.com/repos/square/p2/issues/650","number":650,"state":"open","locked":false,"title":"Stale watches","user":{"login":"rudle","id":41385,"avatar_url":"https://avatars.githubusercontent.com/u/41385?v=3","gravatar_id":"","url":"https://api.github.com/users/rudle","html_url":"https://github.com/rudle","followers_url":"https://api.github.com/users/rudle/followers","following_url":"https://api.github.com/users/rudle/following{/other_user}","gists_url":"https://api.github.com/users/rudle/gists{/gist_id}","starred_url":"https://api.github.com/users/rudle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudle/subscriptions","organizations_url":"https://api.github.com/users/rudle/orgs","repos_url":"https://api.github.com/users/rudle/repos","events_url":"https://api.github.com/users/rudle/events{/privacy}","received_events_url":"https://api.github.com/users/rudle/received_events","type":"User","site_admin":false},"body":"Stale recursive consul list operations are 10x faster than consistent methods and nearly as safe.","created_at":"2016-09-13T20:29:08Z","updated_at":"2016-09-13T22:32:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b549f41c8e0ce73f333e90ac411de5181caed638","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/square/p2/pulls/650/commits","review_comments_url":"https://api.github.com/repos/square/p2/pulls/650/comments","review_comment_url":"https://api.github.com/repos/square/p2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/p2/issues/650/comments","statuses_url":"https://api.github.com/repos/square/p2/statuses/8d37dc492bd5c4586fedf6253d41b064aef786ff","head":{"label":"rudle:stale-watches","ref":"stale-watches","sha":"8d37dc492bd5c4586fedf6253d41b064aef786ff","user":{"login":"rudle","id":41385,"avatar_url":"https://avatars.githubusercontent.com/u/41385?v=3","gravatar_id":"","url":"https://api.github.com/users/rudle","html_url":"https://github.com/rudle","followers_url":"https://api.github.com/users/rudle/followers","following_url":"https://api.github.com/users/rudle/following{/other_user}","gists_url":"https://api.github.com/users/rudle/gists{/gist_id}","starred_url":"https://api.github.com/users/rudle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudle/subscriptions","organizations_url":"https://api.github.com/users/rudle/orgs","repos_url":"https://api.github.com/users/rudle/repos","events_url":"https://api.github.com/users/rudle/events{/privacy}","received_events_url":"https://api.github.com/users/rudle/received_events","type":"User","site_admin":false},"repo":{"id":43720299,"name":"p2","full_name":"rudle/p2","owner":{"login":"rudle","id":41385,"avatar_url":"https://avatars.githubusercontent.com/u/41385?v=3","gravatar_id":"","url":"https://api.github.com/users/rudle","html_url":"https://github.com/rudle","followers_url":"https://api.github.com/users/rudle/followers","following_url":"https://api.github.com/users/rudle/following{/other_user}","gists_url":"https://api.github.com/users/rudle/gists{/gist_id}","starred_url":"https://api.github.com/users/rudle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudle/subscriptions","organizations_url":"https://api.github.com/users/rudle/orgs","repos_url":"https://api.github.com/users/rudle/repos","events_url":"https://api.github.com/users/rudle/events{/privacy}","received_events_url":"https://api.github.com/users/rudle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rudle/p2","description":"Platypus Platform: Tools for Scalable Deployment","fork":true,"url":"https://api.github.com/repos/rudle/p2","forks_url":"https://api.github.com/repos/rudle/p2/forks","keys_url":"https://api.github.com/repos/rudle/p2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rudle/p2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rudle/p2/teams","hooks_url":"https://api.github.com/repos/rudle/p2/hooks","issue_events_url":"https://api.github.com/repos/rudle/p2/issues/events{/number}","events_url":"https://api.github.com/repos/rudle/p2/events","assignees_url":"https://api.github.com/repos/rudle/p2/assignees{/user}","branches_url":"https://api.github.com/repos/rudle/p2/branches{/branch}","tags_url":"https://api.github.com/repos/rudle/p2/tags","blobs_url":"https://api.github.com/repos/rudle/p2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rudle/p2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rudle/p2/git/refs{/sha}","trees_url":"https://api.github.com/repos/rudle/p2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rudle/p2/statuses/{sha}","languages_url":"https://api.github.com/repos/rudle/p2/languages","stargazers_url":"https://api.github.com/repos/rudle/p2/stargazers","contributors_url":"https://api.github.com/repos/rudle/p2/contributors","subscribers_url":"https://api.github.com/repos/rudle/p2/subscribers","subscription_url":"https://api.github.com/repos/rudle/p2/subscription","commits_url":"https://api.github.com/repos/rudle/p2/commits{/sha}","git_commits_url":"https://api.github.com/repos/rudle/p2/git/commits{/sha}","comments_url":"https://api.github.com/repos/rudle/p2/comments{/number}","issue_comment_url":"https://api.github.com/repos/rudle/p2/issues/comments{/number}","contents_url":"https://api.github.com/repos/rudle/p2/contents/{+path}","compare_url":"https://api.github.com/repos/rudle/p2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rudle/p2/merges","archive_url":"https://api.github.com/repos/rudle/p2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rudle/p2/downloads","issues_url":"https://api.github.com/repos/rudle/p2/issues{/number}","pulls_url":"https://api.github.com/repos/rudle/p2/pulls{/number}","milestones_url":"https://api.github.com/repos/rudle/p2/milestones{/number}","notifications_url":"https://api.github.com/repos/rudle/p2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rudle/p2/labels{/name}","releases_url":"https://api.github.com/repos/rudle/p2/releases{/id}","deployments_url":"https://api.github.com/repos/rudle/p2/deployments","created_at":"2015-10-05T23:46:14Z","updated_at":"2016-01-21T18:20:01Z","pushed_at":"2016-09-13T20:27:09Z","git_url":"git://github.com/rudle/p2.git","ssh_url":"git@github.com:rudle/p2.git","clone_url":"https://github.com/rudle/p2.git","svn_url":"https://github.com/rudle/p2","homepage":"","size":49397,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"a7844ad10020a820dc76948e12024ec67a9549f9","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":25320424,"name":"p2","full_name":"square/p2","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/p2","description":"Platypus Platform: Tools for Scalable Deployment","fork":false,"url":"https://api.github.com/repos/square/p2","forks_url":"https://api.github.com/repos/square/p2/forks","keys_url":"https://api.github.com/repos/square/p2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/p2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/p2/teams","hooks_url":"https://api.github.com/repos/square/p2/hooks","issue_events_url":"https://api.github.com/repos/square/p2/issues/events{/number}","events_url":"https://api.github.com/repos/square/p2/events","assignees_url":"https://api.github.com/repos/square/p2/assignees{/user}","branches_url":"https://api.github.com/repos/square/p2/branches{/branch}","tags_url":"https://api.github.com/repos/square/p2/tags","blobs_url":"https://api.github.com/repos/square/p2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/p2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/p2/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/p2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/p2/statuses/{sha}","languages_url":"https://api.github.com/repos/square/p2/languages","stargazers_url":"https://api.github.com/repos/square/p2/stargazers","contributors_url":"https://api.github.com/repos/square/p2/contributors","subscribers_url":"https://api.github.com/repos/square/p2/subscribers","subscription_url":"https://api.github.com/repos/square/p2/subscription","commits_url":"https://api.github.com/repos/square/p2/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/p2/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/p2/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/p2/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/p2/contents/{+path}","compare_url":"https://api.github.com/repos/square/p2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/p2/merges","archive_url":"https://api.github.com/repos/square/p2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/p2/downloads","issues_url":"https://api.github.com/repos/square/p2/issues{/number}","pulls_url":"https://api.github.com/repos/square/p2/pulls{/number}","milestones_url":"https://api.github.com/repos/square/p2/milestones{/number}","notifications_url":"https://api.github.com/repos/square/p2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/p2/labels{/name}","releases_url":"https://api.github.com/repos/square/p2/releases{/id}","deployments_url":"https://api.github.com/repos/square/p2/deployments","created_at":"2014-10-16T20:31:12Z","updated_at":"2016-09-09T21:19:34Z","pushed_at":"2016-09-13T20:29:08Z","git_url":"git://github.com/square/p2.git","ssh_url":"git@github.com:square/p2.git","clone_url":"https://github.com/square/p2.git","svn_url":"https://github.com/square/p2","homepage":"","size":41498,"stargazers_count":123,"watchers_count":123,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":8,"forks":22,"open_issues":8,"watchers":123,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/p2/pulls/650"},"html":{"href":"https://github.com/square/p2/pull/650"},"issue":{"href":"https://api.github.com/repos/square/p2/issues/650"},"comments":{"href":"https://api.github.com/repos/square/p2/issues/650/comments"},"review_comments":{"href":"https://api.github.com/repos/square/p2/pulls/650/comments"},"review_comment":{"href":"https://api.github.com/repos/square/p2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/p2/pulls/650/commits"},"statuses":{"href":"https://api.github.com/repos/square/p2/statuses/8d37dc492bd5c4586fedf6253d41b064aef786ff"}}}}
{"actor":{"display_login":"petertseng"}}