{"action":"created","comment":{"url":"https://api.github.com/repos/apache/kafka/pulls/comments/60921410","id":60921410,"diff_hunk":"@@ -70,19 +72,40 @@ class KafkaHealthcheck(private val brokerId: Int,\n   }\n \n   /**\n-   *  When we get a SessionExpired event, we lost all ephemeral nodes and zkclient has reestablished a\n-   *  connection for us. We need to re-register this broker in the broker registry.\n+   *  When we get a SessionExpired event, it means that we have lost all ephemeral nodes and ZKClient has re-established\n+   *  a connection for us. We need to re-register this broker in the broker registry.\n    */\n-  class SessionExpireListener() extends IZkStateListener {\n+  class SessionExpireListener extends IZkStateListener {\n+\n+    private[server] val stateToSensorMap = {\n+      import KeeperState._\n+      val stateToNameMap = Map(\n+        Disconnected -> \"disconnected\",\n+        SyncConnected -> \"sync-connected\",\n+        AuthFailed -> \"auth-failed\",\n+        ConnectedReadOnly -> \"connected-read-only\",\n+        SaslAuthenticated -> \"sasl-authenticated\",\n+        Expired -> \"expired\"\n+      )\n+      stateToNameMap.map { case (state, stateName) =>\n+        val sensorName = s\"zk-$stateName\"\n+        val sensor = metrics.sensor(sensorName)\n+        sensor.add(metrics.metricName(s\"$sensorName-rate\", \"zk\", s\"The average number of zk $sensorName events per second\"),\n+          new Rate(new Count))\n+        state -> sensor\n+      }\n+    }\n+\n     @throws(classOf[Exception])\n-    def handleStateChanged(state: KeeperState) {}\n+    def handleStateChanged(state: KeeperState) {","path":"core/src/main/scala/kafka/server/KafkaHealthcheck.scala","position":69,"original_position":69,"commit_id":"9f7c7b34bc43f3fe891c90ab614f32c6cbd35f82","original_commit_id":"9f7c7b34bc43f3fe891c90ab614f32c6cbd35f82","user":{"login":"ijuma","id":24747,"avatar_url":"https://avatars.githubusercontent.com/u/24747?v=3","gravatar_id":"","url":"https://api.github.com/users/ijuma","html_url":"https://github.com/ijuma","followers_url":"https://api.github.com/users/ijuma/followers","following_url":"https://api.github.com/users/ijuma/following{/other_user}","gists_url":"https://api.github.com/users/ijuma/gists{/gist_id}","starred_url":"https://api.github.com/users/ijuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ijuma/subscriptions","organizations_url":"https://api.github.com/users/ijuma/orgs","repos_url":"https://api.github.com/users/ijuma/repos","events_url":"https://api.github.com/users/ijuma/events{/privacy}","received_events_url":"https://api.github.com/users/ijuma/received_events","type":"User","site_admin":false},"body":"`override` is only required when overriding non-abstract methods. For cases like this, it's optional and it doesn't help with correctness (if you get the signature wrong and don't override the method, you will get a compiler error). Do you find the `override` keyword useful in such cases?","created_at":"2016-04-25T14:26:33Z","updated_at":"2016-04-25T14:26:33Z","html_url":"https://github.com/apache/kafka/pull/1265#discussion_r60921410","pull_request_url":"https://api.github.com/repos/apache/kafka/pulls/1265","_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments/60921410"},"html":{"href":"https://github.com/apache/kafka/pull/1265#discussion_r60921410"},"pull_request":{"href":"https://api.github.com/repos/apache/kafka/pulls/1265"}}},"pull_request":{"url":"https://api.github.com/repos/apache/kafka/pulls/1265","id":67648633,"html_url":"https://github.com/apache/kafka/pull/1265","diff_url":"https://github.com/apache/kafka/pull/1265.diff","patch_url":"https://github.com/apache/kafka/pull/1265.patch","issue_url":"https://api.github.com/repos/apache/kafka/issues/1265","number":1265,"state":"open","locked":false,"title":"KAFKA-3128; Add metrics for ZooKeeper events zookeeper metrics","user":{"login":"ijuma","id":24747,"avatar_url":"https://avatars.githubusercontent.com/u/24747?v=3","gravatar_id":"","url":"https://api.github.com/users/ijuma","html_url":"https://github.com/ijuma","followers_url":"https://api.github.com/users/ijuma/followers","following_url":"https://api.github.com/users/ijuma/following{/other_user}","gists_url":"https://api.github.com/users/ijuma/gists{/gist_id}","starred_url":"https://api.github.com/users/ijuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ijuma/subscriptions","organizations_url":"https://api.github.com/users/ijuma/orgs","repos_url":"https://api.github.com/users/ijuma/repos","events_url":"https://api.github.com/users/ijuma/events{/privacy}","received_events_url":"https://api.github.com/users/ijuma/received_events","type":"User","site_admin":false},"body":"Also:\r\n* Remove redundant `time.milliseconds` call in `Sensor.record`\r\n* Clean-up a number of tests and remove a manual test that is no longer required","created_at":"2016-04-24T20:17:22Z","updated_at":"2016-04-25T14:26:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6a58661bb885ee11d760184782e40284c5b4d07f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/kafka/pulls/1265/commits","review_comments_url":"https://api.github.com/repos/apache/kafka/pulls/1265/comments","review_comment_url":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/kafka/issues/1265/comments","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/9f7c7b34bc43f3fe891c90ab614f32c6cbd35f82","head":{"label":"ijuma:kafka-3128-zookeeper-metrics","ref":"kafka-3128-zookeeper-metrics","sha":"9f7c7b34bc43f3fe891c90ab614f32c6cbd35f82","user":{"login":"ijuma","id":24747,"avatar_url":"https://avatars.githubusercontent.com/u/24747?v=3","gravatar_id":"","url":"https://api.github.com/users/ijuma","html_url":"https://github.com/ijuma","followers_url":"https://api.github.com/users/ijuma/followers","following_url":"https://api.github.com/users/ijuma/following{/other_user}","gists_url":"https://api.github.com/users/ijuma/gists{/gist_id}","starred_url":"https://api.github.com/users/ijuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ijuma/subscriptions","organizations_url":"https://api.github.com/users/ijuma/orgs","repos_url":"https://api.github.com/users/ijuma/repos","events_url":"https://api.github.com/users/ijuma/events{/privacy}","received_events_url":"https://api.github.com/users/ijuma/received_events","type":"User","site_admin":false},"repo":{"id":32646946,"name":"kafka","full_name":"ijuma/kafka","owner":{"login":"ijuma","id":24747,"avatar_url":"https://avatars.githubusercontent.com/u/24747?v=3","gravatar_id":"","url":"https://api.github.com/users/ijuma","html_url":"https://github.com/ijuma","followers_url":"https://api.github.com/users/ijuma/followers","following_url":"https://api.github.com/users/ijuma/following{/other_user}","gists_url":"https://api.github.com/users/ijuma/gists{/gist_id}","starred_url":"https://api.github.com/users/ijuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ijuma/subscriptions","organizations_url":"https://api.github.com/users/ijuma/orgs","repos_url":"https://api.github.com/users/ijuma/repos","events_url":"https://api.github.com/users/ijuma/events{/privacy}","received_events_url":"https://api.github.com/users/ijuma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ijuma/kafka","description":"Mirror of Apache Kafka","fork":true,"url":"https://api.github.com/repos/ijuma/kafka","forks_url":"https://api.github.com/repos/ijuma/kafka/forks","keys_url":"https://api.github.com/repos/ijuma/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ijuma/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ijuma/kafka/teams","hooks_url":"https://api.github.com/repos/ijuma/kafka/hooks","issue_events_url":"https://api.github.com/repos/ijuma/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/ijuma/kafka/events","assignees_url":"https://api.github.com/repos/ijuma/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/ijuma/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/ijuma/kafka/tags","blobs_url":"https://api.github.com/repos/ijuma/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ijuma/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ijuma/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/ijuma/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ijuma/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/ijuma/kafka/languages","stargazers_url":"https://api.github.com/repos/ijuma/kafka/stargazers","contributors_url":"https://api.github.com/repos/ijuma/kafka/contributors","subscribers_url":"https://api.github.com/repos/ijuma/kafka/subscribers","subscription_url":"https://api.github.com/repos/ijuma/kafka/subscription","commits_url":"https://api.github.com/repos/ijuma/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/ijuma/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/ijuma/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/ijuma/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/ijuma/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/ijuma/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ijuma/kafka/merges","archive_url":"https://api.github.com/repos/ijuma/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ijuma/kafka/downloads","issues_url":"https://api.github.com/repos/ijuma/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/ijuma/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/ijuma/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/ijuma/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ijuma/kafka/labels{/name}","releases_url":"https://api.github.com/repos/ijuma/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/ijuma/kafka/deployments","created_at":"2015-03-21T19:33:59Z","updated_at":"2016-04-15T07:38:43Z","pushed_at":"2016-04-24T20:17:01Z","git_url":"git://github.com/ijuma/kafka.git","ssh_url":"git@github.com:ijuma/kafka.git","clone_url":"https://github.com/ijuma/kafka.git","svn_url":"https://github.com/ijuma/kafka","homepage":null,"size":29737,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"apache:trunk","ref":"trunk","sha":"bc5051565171cf65b4ed7dd4d9ef269d66a1021a","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":2211243,"name":"kafka","full_name":"apache/kafka","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/kafka","description":"Mirror of Apache Kafka","fork":false,"url":"https://api.github.com/repos/apache/kafka","forks_url":"https://api.github.com/repos/apache/kafka/forks","keys_url":"https://api.github.com/repos/apache/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/kafka/teams","hooks_url":"https://api.github.com/repos/apache/kafka/hooks","issue_events_url":"https://api.github.com/repos/apache/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/apache/kafka/events","assignees_url":"https://api.github.com/repos/apache/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/apache/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/apache/kafka/tags","blobs_url":"https://api.github.com/repos/apache/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/kafka/languages","stargazers_url":"https://api.github.com/repos/apache/kafka/stargazers","contributors_url":"https://api.github.com/repos/apache/kafka/contributors","subscribers_url":"https://api.github.com/repos/apache/kafka/subscribers","subscription_url":"https://api.github.com/repos/apache/kafka/subscription","commits_url":"https://api.github.com/repos/apache/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/apache/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/kafka/merges","archive_url":"https://api.github.com/repos/apache/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/kafka/downloads","issues_url":"https://api.github.com/repos/apache/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/apache/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/kafka/labels{/name}","releases_url":"https://api.github.com/repos/apache/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/apache/kafka/deployments","created_at":"2011-08-15T18:06:16Z","updated_at":"2016-04-25T13:31:35Z","pushed_at":"2016-04-25T10:45:36Z","git_url":"git://github.com/apache/kafka.git","ssh_url":"git@github.com:apache/kafka.git","clone_url":"https://github.com/apache/kafka.git","svn_url":"https://github.com/apache/kafka","homepage":null,"size":39832,"stargazers_count":3001,"watchers_count":3001,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1802,"mirror_url":"git://git.apache.org/kafka.git","open_issues_count":197,"forks":1802,"open_issues":197,"watchers":3001,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/1265"},"html":{"href":"https://github.com/apache/kafka/pull/1265"},"issue":{"href":"https://api.github.com/repos/apache/kafka/issues/1265"},"comments":{"href":"https://api.github.com/repos/apache/kafka/issues/1265/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/kafka/pulls/1265/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/kafka/pulls/1265/commits"},"statuses":{"href":"https://api.github.com/repos/apache/kafka/statuses/9f7c7b34bc43f3fe891c90ab614f32c6cbd35f82"}}}}