{"action":"created","comment":{"url":"https://api.github.com/repos/python-diamond/Diamond/pulls/comments/34940094","id":34940094,"diff_hunk":"@@ -5,44 +5,50 @@\n \n #### Dependencies\n \n- * urllib2\n+ * signalfx (pip install signalfx)\n \n \n #### Configuration\n Enable this handler\n \n- * handers = diamond.handler.httpHandler.SignalfxHandler\n+ * handlers = diamond.handler.signalfx_handler.SignalfxHandler\n \n  * auth_token = SIGNALFX_AUTH_TOKEN\n+\n  * batch_size = [optional | 300 ] will wait for this many requests before\n      posting\n \"\"\"\n-\n from Handler import Handler\n-from diamond.util import get_diamond_version\n-import json\n+import collections\n import logging\n import time\n-import urllib2\n+\n+try:\n+    import signalfx\n+except ImportError:\n+    raise ImportError(\"Failed to load signalfx module. \"\n+                      \"Install signalfx module - `pip install signalfx`\")\n+\n+from diamond.util import get_diamond_version\n \n \n class SignalfxHandler(Handler):\n \n     # Inititalize Handler with url and batch size\n     def __init__(self, config=None):\n-        Handler.__init__(self, config)\n+        super(SignalfxHandler, self).__init__(config)\n         self.metrics = []\n+        auth_token = self.config['auth_token']\n+        url = self.config['url']\n         self.batch_size = int(self.config['batch'])\n-        self.url = self.config['url']\n-        self.auth_token = self.config['auth_token']\n-        self.batch_max_interval = self.config['batch_max_interval']\n+        self.batch_max_interval = float(self.config['batch_max_interval'])\n         self.resetBatchTimeout()\n-        if self.auth_token == \"\":\n-            logging.error(\"Failed to load Signalfx module\")\n-            return\n+        self.signalfx = signalfx.SignalFx(auth_token, ingest_endpoint=url,","path":"src/diamond/handler/signalfx_handler.py","position":55,"original_position":55,"commit_id":"2a75c91036c60f2b462b4f4c40eb857b0493951d","original_commit_id":"2a75c91036c60f2b462b4f4c40eb857b0493951d","user":{"login":"baris","id":17591,"avatar_url":"https://avatars.githubusercontent.com/u/17591?v=3","gravatar_id":"","url":"https://api.github.com/users/baris","html_url":"https://github.com/baris","followers_url":"https://api.github.com/users/baris/followers","following_url":"https://api.github.com/users/baris/following{/other_user}","gists_url":"https://api.github.com/users/baris/gists{/gist_id}","starred_url":"https://api.github.com/users/baris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baris/subscriptions","organizations_url":"https://api.github.com/users/baris/orgs","repos_url":"https://api.github.com/users/baris/repos","events_url":"https://api.github.com/users/baris/events{/privacy}","received_events_url":"https://api.github.com/users/baris/received_events","type":"User","site_admin":false},"body":"Looks like this uses the default 1s timeout. Making api post timeout a configuration option for the handler would be very useful.","created_at":"2015-07-17T23:43:21Z","updated_at":"2015-07-17T23:43:21Z","html_url":"https://github.com/python-diamond/Diamond/pull/224#discussion_r34940094","pull_request_url":"https://api.github.com/repos/python-diamond/Diamond/pulls/224","_links":{"self":{"href":"https://api.github.com/repos/python-diamond/Diamond/pulls/comments/34940094"},"html":{"href":"https://github.com/python-diamond/Diamond/pull/224#discussion_r34940094"},"pull_request":{"href":"https://api.github.com/repos/python-diamond/Diamond/pulls/224"}}},"pull_request":{"url":"https://api.github.com/repos/python-diamond/Diamond/pulls/224","id":40189872,"html_url":"https://github.com/python-diamond/Diamond/pull/224","diff_url":"https://github.com/python-diamond/Diamond/pull/224.diff","patch_url":"https://github.com/python-diamond/Diamond/pull/224.patch","issue_url":"https://api.github.com/repos/python-diamond/Diamond/issues/224","number":224,"state":"open","locked":false,"title":"Enabling signalfx handler to use the signalfx python library","user":{"login":"ramjothikumar","id":1501175,"avatar_url":"https://avatars.githubusercontent.com/u/1501175?v=3","gravatar_id":"","url":"https://api.github.com/users/ramjothikumar","html_url":"https://github.com/ramjothikumar","followers_url":"https://api.github.com/users/ramjothikumar/followers","following_url":"https://api.github.com/users/ramjothikumar/following{/other_user}","gists_url":"https://api.github.com/users/ramjothikumar/gists{/gist_id}","starred_url":"https://api.github.com/users/ramjothikumar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramjothikumar/subscriptions","organizations_url":"https://api.github.com/users/ramjothikumar/orgs","repos_url":"https://api.github.com/users/ramjothikumar/repos","events_url":"https://api.github.com/users/ramjothikumar/events{/privacy}","received_events_url":"https://api.github.com/users/ramjothikumar/received_events","type":"User","site_admin":false},"body":"- The signalfx python library has support for Protocol Buffers. To take advantage of this and other enhancements added to the python library, this patch enables the signalfx handler to use the python library.\r\n  This change adds a dependency - signalfx\r\n- Changing batch_max_timestamp type to float to be more accurate during the should_flush calculation.","created_at":"2015-07-17T00:16:50Z","updated_at":"2015-07-17T23:43:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"507f322ea88f54f8c8e4444d29a35c2c1246d75d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/python-diamond/Diamond/pulls/224/commits","review_comments_url":"https://api.github.com/repos/python-diamond/Diamond/pulls/224/comments","review_comment_url":"https://api.github.com/repos/python-diamond/Diamond/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python-diamond/Diamond/issues/224/comments","statuses_url":"https://api.github.com/repos/python-diamond/Diamond/statuses/2a75c91036c60f2b462b4f4c40eb857b0493951d","head":{"label":"ramjothikumar:master","ref":"master","sha":"2a75c91036c60f2b462b4f4c40eb857b0493951d","user":{"login":"ramjothikumar","id":1501175,"avatar_url":"https://avatars.githubusercontent.com/u/1501175?v=3","gravatar_id":"","url":"https://api.github.com/users/ramjothikumar","html_url":"https://github.com/ramjothikumar","followers_url":"https://api.github.com/users/ramjothikumar/followers","following_url":"https://api.github.com/users/ramjothikumar/following{/other_user}","gists_url":"https://api.github.com/users/ramjothikumar/gists{/gist_id}","starred_url":"https://api.github.com/users/ramjothikumar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramjothikumar/subscriptions","organizations_url":"https://api.github.com/users/ramjothikumar/orgs","repos_url":"https://api.github.com/users/ramjothikumar/repos","events_url":"https://api.github.com/users/ramjothikumar/events{/privacy}","received_events_url":"https://api.github.com/users/ramjothikumar/received_events","type":"User","site_admin":false},"repo":{"id":39219693,"name":"Diamond","full_name":"ramjothikumar/Diamond","owner":{"login":"ramjothikumar","id":1501175,"avatar_url":"https://avatars.githubusercontent.com/u/1501175?v=3","gravatar_id":"","url":"https://api.github.com/users/ramjothikumar","html_url":"https://github.com/ramjothikumar","followers_url":"https://api.github.com/users/ramjothikumar/followers","following_url":"https://api.github.com/users/ramjothikumar/following{/other_user}","gists_url":"https://api.github.com/users/ramjothikumar/gists{/gist_id}","starred_url":"https://api.github.com/users/ramjothikumar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramjothikumar/subscriptions","organizations_url":"https://api.github.com/users/ramjothikumar/orgs","repos_url":"https://api.github.com/users/ramjothikumar/repos","events_url":"https://api.github.com/users/ramjothikumar/events{/privacy}","received_events_url":"https://api.github.com/users/ramjothikumar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ramjothikumar/Diamond","description":"Diamond is a python daemon that collects system metrics and publishes them to Graphite (and others). It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.","fork":true,"url":"https://api.github.com/repos/ramjothikumar/Diamond","forks_url":"https://api.github.com/repos/ramjothikumar/Diamond/forks","keys_url":"https://api.github.com/repos/ramjothikumar/Diamond/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ramjothikumar/Diamond/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ramjothikumar/Diamond/teams","hooks_url":"https://api.github.com/repos/ramjothikumar/Diamond/hooks","issue_events_url":"https://api.github.com/repos/ramjothikumar/Diamond/issues/events{/number}","events_url":"https://api.github.com/repos/ramjothikumar/Diamond/events","assignees_url":"https://api.github.com/repos/ramjothikumar/Diamond/assignees{/user}","branches_url":"https://api.github.com/repos/ramjothikumar/Diamond/branches{/branch}","tags_url":"https://api.github.com/repos/ramjothikumar/Diamond/tags","blobs_url":"https://api.github.com/repos/ramjothikumar/Diamond/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ramjothikumar/Diamond/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ramjothikumar/Diamond/git/refs{/sha}","trees_url":"https://api.github.com/repos/ramjothikumar/Diamond/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ramjothikumar/Diamond/statuses/{sha}","languages_url":"https://api.github.com/repos/ramjothikumar/Diamond/languages","stargazers_url":"https://api.github.com/repos/ramjothikumar/Diamond/stargazers","contributors_url":"https://api.github.com/repos/ramjothikumar/Diamond/contributors","subscribers_url":"https://api.github.com/repos/ramjothikumar/Diamond/subscribers","subscription_url":"https://api.github.com/repos/ramjothikumar/Diamond/subscription","commits_url":"https://api.github.com/repos/ramjothikumar/Diamond/commits{/sha}","git_commits_url":"https://api.github.com/repos/ramjothikumar/Diamond/git/commits{/sha}","comments_url":"https://api.github.com/repos/ramjothikumar/Diamond/comments{/number}","issue_comment_url":"https://api.github.com/repos/ramjothikumar/Diamond/issues/comments{/number}","contents_url":"https://api.github.com/repos/ramjothikumar/Diamond/contents/{+path}","compare_url":"https://api.github.com/repos/ramjothikumar/Diamond/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ramjothikumar/Diamond/merges","archive_url":"https://api.github.com/repos/ramjothikumar/Diamond/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ramjothikumar/Diamond/downloads","issues_url":"https://api.github.com/repos/ramjothikumar/Diamond/issues{/number}","pulls_url":"https://api.github.com/repos/ramjothikumar/Diamond/pulls{/number}","milestones_url":"https://api.github.com/repos/ramjothikumar/Diamond/milestones{/number}","notifications_url":"https://api.github.com/repos/ramjothikumar/Diamond/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ramjothikumar/Diamond/labels{/name}","releases_url":"https://api.github.com/repos/ramjothikumar/Diamond/releases{/id}","created_at":"2015-07-16T20:46:59Z","updated_at":"2015-07-16T20:47:01Z","pushed_at":"2015-07-17T00:06:45Z","git_url":"git://github.com/ramjothikumar/Diamond.git","ssh_url":"git@github.com:ramjothikumar/Diamond.git","clone_url":"https://github.com/ramjothikumar/Diamond.git","svn_url":"https://github.com/ramjothikumar/Diamond","homepage":null,"size":2721,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"python-diamond:master","ref":"master","sha":"f9e9cec4f9a8022a4fa9872af745d4f49e589bbd","user":{"login":"python-diamond","id":5668086,"avatar_url":"https://avatars.githubusercontent.com/u/5668086?v=3","gravatar_id":"","url":"https://api.github.com/users/python-diamond","html_url":"https://github.com/python-diamond","followers_url":"https://api.github.com/users/python-diamond/followers","following_url":"https://api.github.com/users/python-diamond/following{/other_user}","gists_url":"https://api.github.com/users/python-diamond/gists{/gist_id}","starred_url":"https://api.github.com/users/python-diamond/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-diamond/subscriptions","organizations_url":"https://api.github.com/users/python-diamond/orgs","repos_url":"https://api.github.com/users/python-diamond/repos","events_url":"https://api.github.com/users/python-diamond/events{/privacy}","received_events_url":"https://api.github.com/users/python-diamond/received_events","type":"Organization","site_admin":false},"repo":{"id":13512018,"name":"Diamond","full_name":"python-diamond/Diamond","owner":{"login":"python-diamond","id":5668086,"avatar_url":"https://avatars.githubusercontent.com/u/5668086?v=3","gravatar_id":"","url":"https://api.github.com/users/python-diamond","html_url":"https://github.com/python-diamond","followers_url":"https://api.github.com/users/python-diamond/followers","following_url":"https://api.github.com/users/python-diamond/following{/other_user}","gists_url":"https://api.github.com/users/python-diamond/gists{/gist_id}","starred_url":"https://api.github.com/users/python-diamond/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-diamond/subscriptions","organizations_url":"https://api.github.com/users/python-diamond/orgs","repos_url":"https://api.github.com/users/python-diamond/repos","events_url":"https://api.github.com/users/python-diamond/events{/privacy}","received_events_url":"https://api.github.com/users/python-diamond/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-diamond/Diamond","description":"Diamond is a python daemon that collects system metrics and publishes them to Graphite (and others). It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.","fork":false,"url":"https://api.github.com/repos/python-diamond/Diamond","forks_url":"https://api.github.com/repos/python-diamond/Diamond/forks","keys_url":"https://api.github.com/repos/python-diamond/Diamond/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-diamond/Diamond/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-diamond/Diamond/teams","hooks_url":"https://api.github.com/repos/python-diamond/Diamond/hooks","issue_events_url":"https://api.github.com/repos/python-diamond/Diamond/issues/events{/number}","events_url":"https://api.github.com/repos/python-diamond/Diamond/events","assignees_url":"https://api.github.com/repos/python-diamond/Diamond/assignees{/user}","branches_url":"https://api.github.com/repos/python-diamond/Diamond/branches{/branch}","tags_url":"https://api.github.com/repos/python-diamond/Diamond/tags","blobs_url":"https://api.github.com/repos/python-diamond/Diamond/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-diamond/Diamond/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-diamond/Diamond/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-diamond/Diamond/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-diamond/Diamond/statuses/{sha}","languages_url":"https://api.github.com/repos/python-diamond/Diamond/languages","stargazers_url":"https://api.github.com/repos/python-diamond/Diamond/stargazers","contributors_url":"https://api.github.com/repos/python-diamond/Diamond/contributors","subscribers_url":"https://api.github.com/repos/python-diamond/Diamond/subscribers","subscription_url":"https://api.github.com/repos/python-diamond/Diamond/subscription","commits_url":"https://api.github.com/repos/python-diamond/Diamond/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-diamond/Diamond/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-diamond/Diamond/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-diamond/Diamond/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-diamond/Diamond/contents/{+path}","compare_url":"https://api.github.com/repos/python-diamond/Diamond/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-diamond/Diamond/merges","archive_url":"https://api.github.com/repos/python-diamond/Diamond/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-diamond/Diamond/downloads","issues_url":"https://api.github.com/repos/python-diamond/Diamond/issues{/number}","pulls_url":"https://api.github.com/repos/python-diamond/Diamond/pulls{/number}","milestones_url":"https://api.github.com/repos/python-diamond/Diamond/milestones{/number}","notifications_url":"https://api.github.com/repos/python-diamond/Diamond/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-diamond/Diamond/labels{/name}","releases_url":"https://api.github.com/repos/python-diamond/Diamond/releases{/id}","created_at":"2013-10-11T23:32:13Z","updated_at":"2015-07-17T12:29:53Z","pushed_at":"2015-07-17T15:50:06Z","git_url":"git://github.com/python-diamond/Diamond.git","ssh_url":"git@github.com:python-diamond/Diamond.git","clone_url":"https://github.com/python-diamond/Diamond.git","svn_url":"https://github.com/python-diamond/Diamond","homepage":null,"size":6188,"stargazers_count":220,"watchers_count":220,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":143,"mirror_url":null,"open_issues_count":97,"forks":143,"open_issues":97,"watchers":220,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python-diamond/Diamond/pulls/224"},"html":{"href":"https://github.com/python-diamond/Diamond/pull/224"},"issue":{"href":"https://api.github.com/repos/python-diamond/Diamond/issues/224"},"comments":{"href":"https://api.github.com/repos/python-diamond/Diamond/issues/224/comments"},"review_comments":{"href":"https://api.github.com/repos/python-diamond/Diamond/pulls/224/comments"},"review_comment":{"href":"https://api.github.com/repos/python-diamond/Diamond/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python-diamond/Diamond/pulls/224/commits"},"statuses":{"href":"https://api.github.com/repos/python-diamond/Diamond/statuses/2a75c91036c60f2b462b4f4c40eb857b0493951d"}}}}