{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/103338670","pull_request_review_id":24122061,"id":103338670,"diff_hunk":"@@ -2,17 +2,48 @@\n # 3p\n from mock import Mock\n import unittest\n+import simplejson as json\n \n # project\n from emitter import (\n     remove_control_chars,\n     remove_undecodable_chars,\n     sanitize_payload,\n+    split_payload\n )\n \n+import os\n+\n+FIXTURE_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'fixtures', 'payloads')\n \n class TestEmitter(unittest.TestCase):\n \n+\n+    def test_payload_splitter(self):\n+        with open(FIXTURE_PATH + '/legacy_payload.json') as f:\n+            legacy_payload = json.load(f)\n+\n+        legacy_payload_split, metrics_payload = split_payload(legacy_payload)\n+        series = metrics_payload['series']\n+        legacy_payload_split['metrics'] = []\n+\n+        for s in series:\n+            attributes = {}\n+\n+            if s.get('type'):\n+                attributes['type'] = s['type']\n+            if s.get('host'):\n+                attributes['hostname'] = s['host']\n+            if s.get('tags'):\n+                attributes['tags'] = s['tags']\n+            if s.get('device'):\n+                attributes['device_name'] = s['device']\n+\n+            formatted_sample = [s['metric'], s['points'][0][0], s['points'][0][1], attributes]\n+            legacy_payload_split['metrics'].append(formatted_sample)\n+\n+        self.assertEqual(legacy_payload, legacy_payload_split)","path":"tests/core/test_emitter.py","position":44,"original_position":44,"commit_id":"b783555de36236b53fb712dc2ca441c3d24a7a26","original_commit_id":"b783555de36236b53fb712dc2ca441c3d24a7a26","user":{"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},"body":"good catch :man_facepalming: ","created_at":"2017-02-27T23:20:01Z","updated_at":"2017-02-27T23:20:01Z","html_url":"https://github.com/DataDog/dd-agent/pull/3180#discussion_r103338670","pull_request_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/3180","_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/103338670"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/3180#discussion_r103338670"},"pull_request":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/3180"}}},"pull_request":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/3180","id":105329998,"html_url":"https://github.com/DataDog/dd-agent/pull/3180","diff_url":"https://github.com/DataDog/dd-agent/pull/3180.diff","patch_url":"https://github.com/DataDog/dd-agent/pull/3180.patch","issue_url":"https://api.github.com/repos/DataDog/dd-agent/issues/3180","number":3180,"state":"open","locked":false,"title":"[core] Submitting metrics to the api endpoint","user":{"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},"body":"### What does this PR do?\r\n\r\nThis PR splits the collector payload into a `legacy` payload and a `metrics` payload.\r\n\r\nIt does so by extracting the metrics that are in the \"new\" format from the current payload, transforming them, a putting them into a new payload to be posted to the `api/v1/series` endpoint.\r\n\r\n### Motivation\r\n\r\nThis will help up phasing out a backend service used by the old payload.\r\n\r\n\r\n### Testing Guidelines\r\n\r\n - Added a unit test on the split function\r\n - Tested that this was a no op on my agent (i.e. all metrics keep flowing seamlessly)\r\n - This will need to be tested at higher scale as well during QA.\r\n\r\n","created_at":"2017-02-08T23:34:17Z","updated_at":"2017-02-27T23:20:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d159e6b3c9ee1442e1b523f1c0ba95f57529c4a","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/DataDog/dd-agent/milestones/79","html_url":"https://github.com/DataDog/dd-agent/milestone/79","labels_url":"https://api.github.com/repos/DataDog/dd-agent/milestones/79/labels","id":2265876,"number":79,"title":"5.12.0","description":"","creator":{"login":"olivielpeau","id":4912500,"avatar_url":"https://avatars.githubusercontent.com/u/4912500?v=3","gravatar_id":"","url":"https://api.github.com/users/olivielpeau","html_url":"https://github.com/olivielpeau","followers_url":"https://api.github.com/users/olivielpeau/followers","following_url":"https://api.github.com/users/olivielpeau/following{/other_user}","gists_url":"https://api.github.com/users/olivielpeau/gists{/gist_id}","starred_url":"https://api.github.com/users/olivielpeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivielpeau/subscriptions","organizations_url":"https://api.github.com/users/olivielpeau/orgs","repos_url":"https://api.github.com/users/olivielpeau/repos","events_url":"https://api.github.com/users/olivielpeau/events{/privacy}","received_events_url":"https://api.github.com/users/olivielpeau/received_events","type":"User","site_admin":false},"open_issues":31,"closed_issues":97,"state":"open","created_at":"2017-01-20T00:57:56Z","updated_at":"2017-02-24T17:25:35Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/3180/commits","review_comments_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/3180/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/3180/comments","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/b783555de36236b53fb712dc2ca441c3d24a7a26","head":{"label":"DataDog:remh/split_payloads","ref":"remh/split_payloads","sha":"b783555de36236b53fb712dc2ca441c3d24a7a26","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}","deployments_url":"https://api.github.com/repos/DataDog/dd-agent/deployments","created_at":"2010-12-31T03:02:47Z","updated_at":"2017-02-27T17:26:48Z","pushed_at":"2017-02-27T23:02:36Z","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":"https://docs.datadoghq.com/","size":40551,"stargazers_count":743,"watchers_count":743,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":690,"mirror_url":null,"open_issues_count":232,"forks":690,"open_issues":232,"watchers":743,"default_branch":"master"}},"base":{"label":"DataDog:master","ref":"master","sha":"6ff1f1cf1f02ee89c3d127bc3e18a7b3940d4e8a","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}","deployments_url":"https://api.github.com/repos/DataDog/dd-agent/deployments","created_at":"2010-12-31T03:02:47Z","updated_at":"2017-02-27T17:26:48Z","pushed_at":"2017-02-27T23:02:36Z","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":"https://docs.datadoghq.com/","size":40551,"stargazers_count":743,"watchers_count":743,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":690,"mirror_url":null,"open_issues_count":232,"forks":690,"open_issues":232,"watchers":743,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/3180"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/3180"},"issue":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/3180"},"comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/3180/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/3180/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/3180/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/dd-agent/statuses/b783555de36236b53fb712dc2ca441c3d24a7a26"}}}}
{"actor":{"display_login":"remh"}}