{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/29761861","id":29761861,"diff_hunk":"@@ -1,20 +1,29 @@\n # stdlib\n from collections import defaultdict\n-import random\n \n-# project\n-from checks import AgentCheck\n-\n-# 3rd party\n+# 3p\n from kafka.client import KafkaClient\n from kafka.common import OffsetRequest\n from kazoo.client import KazooClient\n from kazoo.exceptions import NoNodeError\n \n+# project\n+from checks import AgentCheck\n+\n+DEFAULT_KAFKA_TIMEOUT = 5\n+DEFAULT_ZK_TIMEOUT = 5\n+\n+\n class KafkaCheck(AgentCheck):\n \n     SOURCE_TYPE_NAME = 'kafka'\n \n+    def __init__(self, name, init_config, agentConfig, instances=None):\n+        self.zk_timeout = int(\n+            init_config.get('zk_timeout', DEFAULT_ZK_TIMEOUT))\n+        self.kafka_timeout = int(\n+            init_config.get('kafka_timeout', DEFAULT_KAFKA_TIMEOUT))\n+","path":"checks.d/kafka_consumer.py","position":31,"original_position":31,"commit_id":"d068d46d8cc5f9d21e5bf4ddfe100079279a2553","original_commit_id":"d068d46d8cc5f9d21e5bf4ddfe100079279a2553","user":{"login":"LeoCavaille","id":1788830,"avatar_url":"https://avatars.githubusercontent.com/u/1788830?v=3","gravatar_id":"","url":"https://api.github.com/users/LeoCavaille","html_url":"https://github.com/LeoCavaille","followers_url":"https://api.github.com/users/LeoCavaille/followers","following_url":"https://api.github.com/users/LeoCavaille/following{/other_user}","gists_url":"https://api.github.com/users/LeoCavaille/gists{/gist_id}","starred_url":"https://api.github.com/users/LeoCavaille/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LeoCavaille/subscriptions","organizations_url":"https://api.github.com/users/LeoCavaille/orgs","repos_url":"https://api.github.com/users/LeoCavaille/repos","events_url":"https://api.github.com/users/LeoCavaille/events{/privacy}","received_events_url":"https://api.github.com/users/LeoCavaille/received_events","type":"User","site_admin":false},"body":"Wow good catch! :+1: ","created_at":"2015-05-06T14:17:05Z","updated_at":"2015-05-06T14:17:05Z","html_url":"https://github.com/DataDog/dd-agent/pull/1592#discussion_r29761861","pull_request_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1592","_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/29761861"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/1592#discussion_r29761861"},"pull_request":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1592"}}},"pull_request":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1592","id":34679410,"html_url":"https://github.com/DataDog/dd-agent/pull/1592","diff_url":"https://github.com/DataDog/dd-agent/pull/1592.diff","patch_url":"https://github.com/DataDog/dd-agent/pull/1592.patch","issue_url":"https://api.github.com/repos/DataDog/dd-agent/issues/1592","number":1592,"state":"open","locked":false,"title":"[kafka_consumer] add timeout for zk/kafka connections","user":{"login":"LeoCavaille","id":1788830,"avatar_url":"https://avatars.githubusercontent.com/u/1788830?v=3","gravatar_id":"","url":"https://api.github.com/users/LeoCavaille","html_url":"https://github.com/LeoCavaille","followers_url":"https://api.github.com/users/LeoCavaille/followers","following_url":"https://api.github.com/users/LeoCavaille/following{/other_user}","gists_url":"https://api.github.com/users/LeoCavaille/gists{/gist_id}","starred_url":"https://api.github.com/users/LeoCavaille/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LeoCavaille/subscriptions","organizations_url":"https://api.github.com/users/LeoCavaille/orgs","repos_url":"https://api.github.com/users/LeoCavaille/repos","events_url":"https://api.github.com/users/LeoCavaille/events{/privacy}","received_events_url":"https://api.github.com/users/LeoCavaille/received_events","type":"User","site_admin":false},"body":"Because the default timeouts are pretty high in the kafka-python and\r\nkazoo library (resp. 120s and 10s), we put them at a much lower\r\nthreshold (5s) for the default cases and offer a way to override in the\r\nYAML init_config section.\r\n\r\nFixes #1589.","created_at":"2015-05-04T21:56:52Z","updated_at":"2015-05-06T14:17:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b61dfc892509744e5d73224182e3f9e5a9dfdc01","assignee":{"login":"degemer","id":4912048,"avatar_url":"https://avatars.githubusercontent.com/u/4912048?v=3","gravatar_id":"","url":"https://api.github.com/users/degemer","html_url":"https://github.com/degemer","followers_url":"https://api.github.com/users/degemer/followers","following_url":"https://api.github.com/users/degemer/following{/other_user}","gists_url":"https://api.github.com/users/degemer/gists{/gist_id}","starred_url":"https://api.github.com/users/degemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/degemer/subscriptions","organizations_url":"https://api.github.com/users/degemer/orgs","repos_url":"https://api.github.com/users/degemer/repos","events_url":"https://api.github.com/users/degemer/events{/privacy}","received_events_url":"https://api.github.com/users/degemer/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/DataDog/dd-agent/milestones/43","html_url":"https://github.com/DataDog/dd-agent/milestones/5.4.0","labels_url":"https://api.github.com/repos/DataDog/dd-agent/milestones/43/labels","id":996033,"number":43,"title":"5.4.0","description":null,"creator":{"login":"remh","id":1311477,"avatar_url":"https://avatars.githubusercontent.com/u/1311477?v=3","gravatar_id":"","url":"https://api.github.com/users/remh","html_url":"https://github.com/remh","followers_url":"https://api.github.com/users/remh/followers","following_url":"https://api.github.com/users/remh/following{/other_user}","gists_url":"https://api.github.com/users/remh/gists{/gist_id}","starred_url":"https://api.github.com/users/remh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remh/subscriptions","organizations_url":"https://api.github.com/users/remh/orgs","repos_url":"https://api.github.com/users/remh/repos","events_url":"https://api.github.com/users/remh/events{/privacy}","received_events_url":"https://api.github.com/users/remh/received_events","type":"User","site_admin":false},"open_issues":52,"closed_issues":15,"state":"open","created_at":"2015-02-25T23:32:42Z","updated_at":"2015-05-06T14:14:22Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1592/commits","review_comments_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1592/comments","review_comment_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DataDog/dd-agent/issues/1592/comments","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/d068d46d8cc5f9d21e5bf4ddfe100079279a2553","head":{"label":"DataDog:leo/kafkatimeout","ref":"leo/kafkatimeout","sha":"d068d46d8cc5f9d21e5bf4ddfe100079279a2553","user":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":1210071,"name":"dd-agent","full_name":"DataDog/dd-agent","owner":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DataDog/dd-agent","description":"Datadog Agent","fork":false,"url":"https://api.github.com/repos/DataDog/dd-agent","forks_url":"https://api.github.com/repos/DataDog/dd-agent/forks","keys_url":"https://api.github.com/repos/DataDog/dd-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/dd-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/dd-agent/teams","hooks_url":"https://api.github.com/repos/DataDog/dd-agent/hooks","issue_events_url":"https://api.github.com/repos/DataDog/dd-agent/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/dd-agent/events","assignees_url":"https://api.github.com/repos/DataDog/dd-agent/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/dd-agent/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/dd-agent/tags","blobs_url":"https://api.github.com/repos/DataDog/dd-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/dd-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/dd-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/dd-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/dd-agent/languages","stargazers_url":"https://api.github.com/repos/DataDog/dd-agent/stargazers","contributors_url":"https://api.github.com/repos/DataDog/dd-agent/contributors","subscribers_url":"https://api.github.com/repos/DataDog/dd-agent/subscribers","subscription_url":"https://api.github.com/repos/DataDog/dd-agent/subscription","commits_url":"https://api.github.com/repos/DataDog/dd-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/dd-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/dd-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/dd-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/dd-agent/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/dd-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/dd-agent/merges","archive_url":"https://api.github.com/repos/DataDog/dd-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/dd-agent/downloads","issues_url":"https://api.github.com/repos/DataDog/dd-agent/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/dd-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/dd-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/dd-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/dd-agent/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/dd-agent/releases{/id}","created_at":"2010-12-31T03:02:47Z","updated_at":"2015-05-05T23:46:36Z","pushed_at":"2015-05-06T14:08:53Z","git_url":"git://github.com/DataDog/dd-agent.git","ssh_url":"git@github.com:DataDog/dd-agent.git","clone_url":"https://github.com/DataDog/dd-agent.git","svn_url":"https://github.com/DataDog/dd-agent","homepage":"http://docs.datadoghq.com/","size":52270,"stargazers_count":274,"watchers_count":274,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":204,"mirror_url":null,"open_issues_count":171,"forks":204,"open_issues":171,"watchers":274,"default_branch":"master"}},"base":{"label":"DataDog:master","ref":"master","sha":"cc3c725cf1e19eb778f49372cba4c15f8c7a270f","user":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":1210071,"name":"dd-agent","full_name":"DataDog/dd-agent","owner":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DataDog/dd-agent","description":"Datadog Agent","fork":false,"url":"https://api.github.com/repos/DataDog/dd-agent","forks_url":"https://api.github.com/repos/DataDog/dd-agent/forks","keys_url":"https://api.github.com/repos/DataDog/dd-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/dd-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/dd-agent/teams","hooks_url":"https://api.github.com/repos/DataDog/dd-agent/hooks","issue_events_url":"https://api.github.com/repos/DataDog/dd-agent/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/dd-agent/events","assignees_url":"https://api.github.com/repos/DataDog/dd-agent/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/dd-agent/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/dd-agent/tags","blobs_url":"https://api.github.com/repos/DataDog/dd-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/dd-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/dd-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/dd-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/dd-agent/languages","stargazers_url":"https://api.github.com/repos/DataDog/dd-agent/stargazers","contributors_url":"https://api.github.com/repos/DataDog/dd-agent/contributors","subscribers_url":"https://api.github.com/repos/DataDog/dd-agent/subscribers","subscription_url":"https://api.github.com/repos/DataDog/dd-agent/subscription","commits_url":"https://api.github.com/repos/DataDog/dd-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/dd-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/dd-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/dd-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/dd-agent/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/dd-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/dd-agent/merges","archive_url":"https://api.github.com/repos/DataDog/dd-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/dd-agent/downloads","issues_url":"https://api.github.com/repos/DataDog/dd-agent/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/dd-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/dd-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/dd-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/dd-agent/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/dd-agent/releases{/id}","created_at":"2010-12-31T03:02:47Z","updated_at":"2015-05-05T23:46:36Z","pushed_at":"2015-05-06T14:08:53Z","git_url":"git://github.com/DataDog/dd-agent.git","ssh_url":"git@github.com:DataDog/dd-agent.git","clone_url":"https://github.com/DataDog/dd-agent.git","svn_url":"https://github.com/DataDog/dd-agent","homepage":"http://docs.datadoghq.com/","size":52270,"stargazers_count":274,"watchers_count":274,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":204,"mirror_url":null,"open_issues_count":171,"forks":204,"open_issues":171,"watchers":274,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1592"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/1592"},"issue":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/1592"},"comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/1592/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1592/comments"},"review_comment":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1592/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/dd-agent/statuses/d068d46d8cc5f9d21e5bf4ddfe100079279a2553"}}}}