{"action":"created","comment":{"url":"https://api.github.com/repos/qiniu/logkit/pulls/comments/230980490","pull_request_review_id":171841767,"id":230980490,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMDk4MDQ5MA==","diff_hunk":"@@ -484,7 +510,99 @@ func TestHTTPSenderNoGzipWithRaw(t *testing.T) {\n \tassert.Equal(t, \"aaaaIf newbie have bad time,it's a bug on logkit!!!\", res)\n }\n \n-func TestGzipData(t *testing.T) {\n+func TestHTTPSenderJSONWithTemplate(t *testing.T) {\n+\tt.Parallel()\n+\trunnerName := \"TestHTTPSenderJSONWithTamplate\"\n+\n+\thttpReader, err := newHTTPReader(runnerName, \"8007\")\n+\tassert.NoError(t, err)\n+\tdefer func() {\n+\t\tos.RemoveAll(\"./meta/\" + runnerName)\n+\t\thttpReader.Close()\n+\t}()\n+\n+\t//\t// CI 环境启动监听较慢，需要等待几秒\n+\ttime.Sleep(2 * time.Second)\n+\n+\thttpSender, err := NewSender(conf.MapConf{\n+\t\tsender.KeyHttpSenderGzip:     \"false\",\n+\t\tsender.KeyHttpSenderCsvSplit: \"\\t\",\n+\t\tsender.KeyHttpSenderProtocol: \"json\",\n+\t\tsender.KeyHttpSenderCsvHead:  \"false\",\n+\t\tsender.KeyHttpSenderTemplate: templateExp,\n+\t\tKeyRunnerName:                runnerName,\n+\t\tsender.KeyHttpSenderUrl:      \"http://127.0.0.1:8007/logkit/data\",\n+\t})\n+\tassert.NoError(t, err)\n+\tvar wg sync.WaitGroup\n+\tfor _, val := range testData {\n+\t\twg.Add(1)\n+\t\tgo func(httpReader *http.Reader, val struct {\n+\t\t\tinput               []Data\n+\t\t\tjsonExp             [][]string\n+\t\t\tcsvExp              []map[string]string\n+\t\t\tbodyJSONExp         string\n+\t\t\ttemplateJSONExp     []string\n+\t\t\ttemplateBodyJSONExp string\n+\t\t}, t *testing.T) {\n+\t\t\tfor _, exp := range val.templateJSONExp {\n+\t\t\t\tgot, err := httpReader.ReadLine()\n+\t\t\t\tassert.NoError(t, err)\n+\t\t\t\tassert.Equal(t, got, exp)\n+\t\t\t}\n+\t\t\twg.Done()\n+\t\t}(httpReader, val, t)\n+\t\tassert.NoError(t, httpSender.Send(val.input))\n+\t}\n+\twg.Wait()\n+}\n+\n+func TestHTTPSenderJSONBodyWithTemplate(t *testing.T) {\n+\tt.Parallel()\n+\trunnerName := \"TestHTTPSenderJSONWithTamplate\"\n+\n+\thttpReader, err := newHTTPReader(runnerName, \"8008\")\n+\tassert.NoError(t, err)\n+\tdefer func() {\n+\t\tos.RemoveAll(\"./meta/\" + runnerName)\n+\t\thttpReader.Close()\n+\t}()\n+\n+\t//\t// CI 环境启动监听较慢，需要等待几秒\n+\ttime.Sleep(2 * time.Second)\n+\n+\thttpSender, err := NewSender(conf.MapConf{\n+\t\tsender.KeyHttpSenderGzip:     \"false\",\n+\t\tsender.KeyHttpSenderCsvSplit: \"\\t\",\n+\t\tsender.KeyHttpSenderProtocol: \"body_json\",\n+\t\tsender.KeyHttpSenderCsvHead:  \"false\",\n+\t\tsender.KeyHttpSenderTemplate: templateExp,\n+\t\tKeyRunnerName:                runnerName,\n+\t\tsender.KeyHttpSenderUrl:      \"http://127.0.0.1:8008/logkit/data\",\n+\t})\n+\tassert.NoError(t, err)\n+\tvar wg sync.WaitGroup\n+\tfor _, val := range testData {\n+\t\twg.Add(1)\n+\t\tgo func(httpReader *http.Reader, val struct {\n+\t\t\tinput               []Data\n+\t\t\tjsonExp             [][]string\n+\t\t\tcsvExp              []map[string]string\n+\t\t\tbodyJSONExp         string\n+\t\t\ttemplateJSONExp     []string\n+\t\t\ttemplateBodyJSONExp string\n+\t\t}, t *testing.T) {\n+\t\t\tgot, err := httpReader.ReadLine()\n+\t\t\tassert.NoError(t, err)\n+\t\t\tassert.Equal(t, got, val.templateBodyJSONExp)\n+\t\t\twg.Done()\n+\t\t}(httpReader, val, t)\n+\t\tassert.NoError(t, httpSender.Send(val.input))\n+\t}\n+\twg.Wait()\n+}\n+\n+func _TestGzipData(t *testing.T) {","path":"sender/http/http_test.go","position":283,"original_position":283,"commit_id":"b73f886c3730aca7d0fbafb31e6d22fa162adc9a","original_commit_id":"b73f886c3730aca7d0fbafb31e6d22fa162adc9a","user":{"login":"wonderflow","id":2173670,"node_id":"MDQ6VXNlcjIxNzM2NzA=","avatar_url":"https://avatars0.githubusercontent.com/u/2173670?v=4","gravatar_id":"","url":"https://api.github.com/users/wonderflow","html_url":"https://github.com/wonderflow","followers_url":"https://api.github.com/users/wonderflow/followers","following_url":"https://api.github.com/users/wonderflow/following{/other_user}","gists_url":"https://api.github.com/users/wonderflow/gists{/gist_id}","starred_url":"https://api.github.com/users/wonderflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wonderflow/subscriptions","organizations_url":"https://api.github.com/users/wonderflow/orgs","repos_url":"https://api.github.com/users/wonderflow/repos","events_url":"https://api.github.com/users/wonderflow/events{/privacy}","received_events_url":"https://api.github.com/users/wonderflow/received_events","type":"User","site_admin":false},"body":"这个前面加下划线是什么效果","created_at":"2018-11-06T02:09:15Z","updated_at":"2018-11-06T02:09:16Z","html_url":"https://github.com/qiniu/logkit/pull/808#discussion_r230980490","pull_request_url":"https://api.github.com/repos/qiniu/logkit/pulls/808","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/qiniu/logkit/pulls/comments/230980490"},"html":{"href":"https://github.com/qiniu/logkit/pull/808#discussion_r230980490"},"pull_request":{"href":"https://api.github.com/repos/qiniu/logkit/pulls/808"}}},"pull_request":{"url":"https://api.github.com/repos/qiniu/logkit/pulls/808","id":227534008,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3NTM0MDA4","html_url":"https://github.com/qiniu/logkit/pull/808","diff_url":"https://github.com/qiniu/logkit/pull/808.diff","patch_url":"https://github.com/qiniu/logkit/pull/808.patch","issue_url":"https://api.github.com/repos/qiniu/logkit/issues/808","number":808,"state":"open","locked":false,"title":"http sender支持自定义格式模板发送","user":{"login":"sven0726","id":4318521,"node_id":"MDQ6VXNlcjQzMTg1MjE=","avatar_url":"https://avatars0.githubusercontent.com/u/4318521?v=4","gravatar_id":"","url":"https://api.github.com/users/sven0726","html_url":"https://github.com/sven0726","followers_url":"https://api.github.com/users/sven0726/followers","following_url":"https://api.github.com/users/sven0726/following{/other_user}","gists_url":"https://api.github.com/users/sven0726/gists{/gist_id}","starred_url":"https://api.github.com/users/sven0726/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sven0726/subscriptions","organizations_url":"https://api.github.com/users/sven0726/orgs","repos_url":"https://api.github.com/users/sven0726/repos","events_url":"https://api.github.com/users/sven0726/events{/privacy}","received_events_url":"https://api.github.com/users/sven0726/received_events","type":"User","site_admin":false},"body":"## Fixes [PDR-7865](https://jira.qiniu.io/browse/PDR-7865)\r\n\r\n## Changes\r\n   \r\n- [x] http sender支持自定义格式模板发送\r\n \r\n## Reviewers\r\n\r\n- [x] @wonderflow  please review\r\n\r\n## Wiki Changes\r\n \r\n- options1...\r\n- options2...\r\n    \r\n## Checklist\r\n   \r\n- [ ] Rebased/mergeable\r\n- [ ] Tests pass\r\n- [ ] Wiki updated\r\n","created_at":"2018-11-01T07:21:16Z","updated_at":"2018-11-06T02:09:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c29f053d2d8ee38ff6f10f3e982c2bc2d604384e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/qiniu/logkit/pulls/808/commits","review_comments_url":"https://api.github.com/repos/qiniu/logkit/pulls/808/comments","review_comment_url":"https://api.github.com/repos/qiniu/logkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/qiniu/logkit/issues/808/comments","statuses_url":"https://api.github.com/repos/qiniu/logkit/statuses/b73f886c3730aca7d0fbafb31e6d22fa162adc9a","head":{"label":"sven0726:master","ref":"master","sha":"b73f886c3730aca7d0fbafb31e6d22fa162adc9a","user":{"login":"sven0726","id":4318521,"node_id":"MDQ6VXNlcjQzMTg1MjE=","avatar_url":"https://avatars0.githubusercontent.com/u/4318521?v=4","gravatar_id":"","url":"https://api.github.com/users/sven0726","html_url":"https://github.com/sven0726","followers_url":"https://api.github.com/users/sven0726/followers","following_url":"https://api.github.com/users/sven0726/following{/other_user}","gists_url":"https://api.github.com/users/sven0726/gists{/gist_id}","starred_url":"https://api.github.com/users/sven0726/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sven0726/subscriptions","organizations_url":"https://api.github.com/users/sven0726/orgs","repos_url":"https://api.github.com/users/sven0726/repos","events_url":"https://api.github.com/users/sven0726/events{/privacy}","received_events_url":"https://api.github.com/users/sven0726/received_events","type":"User","site_admin":false},"repo":{"id":116638757,"node_id":"MDEwOlJlcG9zaXRvcnkxMTY2Mzg3NTc=","name":"logkit","full_name":"sven0726/logkit","private":false,"owner":{"login":"sven0726","id":4318521,"node_id":"MDQ6VXNlcjQzMTg1MjE=","avatar_url":"https://avatars0.githubusercontent.com/u/4318521?v=4","gravatar_id":"","url":"https://api.github.com/users/sven0726","html_url":"https://github.com/sven0726","followers_url":"https://api.github.com/users/sven0726/followers","following_url":"https://api.github.com/users/sven0726/following{/other_user}","gists_url":"https://api.github.com/users/sven0726/gists{/gist_id}","starred_url":"https://api.github.com/users/sven0726/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sven0726/subscriptions","organizations_url":"https://api.github.com/users/sven0726/orgs","repos_url":"https://api.github.com/users/sven0726/repos","events_url":"https://api.github.com/users/sven0726/events{/privacy}","received_events_url":"https://api.github.com/users/sven0726/received_events","type":"User","site_admin":false},"html_url":"https://github.com/sven0726/logkit","description":"Very easy-to-use server agent for collecting & sending logs & metrics.","fork":true,"url":"https://api.github.com/repos/sven0726/logkit","forks_url":"https://api.github.com/repos/sven0726/logkit/forks","keys_url":"https://api.github.com/repos/sven0726/logkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sven0726/logkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sven0726/logkit/teams","hooks_url":"https://api.github.com/repos/sven0726/logkit/hooks","issue_events_url":"https://api.github.com/repos/sven0726/logkit/issues/events{/number}","events_url":"https://api.github.com/repos/sven0726/logkit/events","assignees_url":"https://api.github.com/repos/sven0726/logkit/assignees{/user}","branches_url":"https://api.github.com/repos/sven0726/logkit/branches{/branch}","tags_url":"https://api.github.com/repos/sven0726/logkit/tags","blobs_url":"https://api.github.com/repos/sven0726/logkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sven0726/logkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sven0726/logkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/sven0726/logkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sven0726/logkit/statuses/{sha}","languages_url":"https://api.github.com/repos/sven0726/logkit/languages","stargazers_url":"https://api.github.com/repos/sven0726/logkit/stargazers","contributors_url":"https://api.github.com/repos/sven0726/logkit/contributors","subscribers_url":"https://api.github.com/repos/sven0726/logkit/subscribers","subscription_url":"https://api.github.com/repos/sven0726/logkit/subscription","commits_url":"https://api.github.com/repos/sven0726/logkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/sven0726/logkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/sven0726/logkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/sven0726/logkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/sven0726/logkit/contents/{+path}","compare_url":"https://api.github.com/repos/sven0726/logkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sven0726/logkit/merges","archive_url":"https://api.github.com/repos/sven0726/logkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sven0726/logkit/downloads","issues_url":"https://api.github.com/repos/sven0726/logkit/issues{/number}","pulls_url":"https://api.github.com/repos/sven0726/logkit/pulls{/number}","milestones_url":"https://api.github.com/repos/sven0726/logkit/milestones{/number}","notifications_url":"https://api.github.com/repos/sven0726/logkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sven0726/logkit/labels{/name}","releases_url":"https://api.github.com/repos/sven0726/logkit/releases{/id}","deployments_url":"https://api.github.com/repos/sven0726/logkit/deployments","created_at":"2018-01-08T06:28:36Z","updated_at":"2018-01-08T06:30:16Z","pushed_at":"2018-11-05T10:40:43Z","git_url":"git://github.com/sven0726/logkit.git","ssh_url":"git@github.com:sven0726/logkit.git","clone_url":"https://github.com/sven0726/logkit.git","svn_url":"https://github.com/sven0726/logkit","homepage":"https://qiniu.github.io/pandora-docs/#/util/logkit","size":21106,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"qiniu:master","ref":"master","sha":"76731bcaa8735eefe1e5a1e7af8a85e54736c087","user":{"login":"qiniu","id":1563636,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NjM2MzY=","avatar_url":"https://avatars2.githubusercontent.com/u/1563636?v=4","gravatar_id":"","url":"https://api.github.com/users/qiniu","html_url":"https://github.com/qiniu","followers_url":"https://api.github.com/users/qiniu/followers","following_url":"https://api.github.com/users/qiniu/following{/other_user}","gists_url":"https://api.github.com/users/qiniu/gists{/gist_id}","starred_url":"https://api.github.com/users/qiniu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiniu/subscriptions","organizations_url":"https://api.github.com/users/qiniu/orgs","repos_url":"https://api.github.com/users/qiniu/repos","events_url":"https://api.github.com/users/qiniu/events{/privacy}","received_events_url":"https://api.github.com/users/qiniu/received_events","type":"Organization","site_admin":false},"repo":{"id":91304426,"node_id":"MDEwOlJlcG9zaXRvcnk5MTMwNDQyNg==","name":"logkit","full_name":"qiniu/logkit","private":false,"owner":{"login":"qiniu","id":1563636,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NjM2MzY=","avatar_url":"https://avatars2.githubusercontent.com/u/1563636?v=4","gravatar_id":"","url":"https://api.github.com/users/qiniu","html_url":"https://github.com/qiniu","followers_url":"https://api.github.com/users/qiniu/followers","following_url":"https://api.github.com/users/qiniu/following{/other_user}","gists_url":"https://api.github.com/users/qiniu/gists{/gist_id}","starred_url":"https://api.github.com/users/qiniu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiniu/subscriptions","organizations_url":"https://api.github.com/users/qiniu/orgs","repos_url":"https://api.github.com/users/qiniu/repos","events_url":"https://api.github.com/users/qiniu/events{/privacy}","received_events_url":"https://api.github.com/users/qiniu/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/qiniu/logkit","description":"Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.","fork":false,"url":"https://api.github.com/repos/qiniu/logkit","forks_url":"https://api.github.com/repos/qiniu/logkit/forks","keys_url":"https://api.github.com/repos/qiniu/logkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qiniu/logkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qiniu/logkit/teams","hooks_url":"https://api.github.com/repos/qiniu/logkit/hooks","issue_events_url":"https://api.github.com/repos/qiniu/logkit/issues/events{/number}","events_url":"https://api.github.com/repos/qiniu/logkit/events","assignees_url":"https://api.github.com/repos/qiniu/logkit/assignees{/user}","branches_url":"https://api.github.com/repos/qiniu/logkit/branches{/branch}","tags_url":"https://api.github.com/repos/qiniu/logkit/tags","blobs_url":"https://api.github.com/repos/qiniu/logkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qiniu/logkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qiniu/logkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/qiniu/logkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qiniu/logkit/statuses/{sha}","languages_url":"https://api.github.com/repos/qiniu/logkit/languages","stargazers_url":"https://api.github.com/repos/qiniu/logkit/stargazers","contributors_url":"https://api.github.com/repos/qiniu/logkit/contributors","subscribers_url":"https://api.github.com/repos/qiniu/logkit/subscribers","subscription_url":"https://api.github.com/repos/qiniu/logkit/subscription","commits_url":"https://api.github.com/repos/qiniu/logkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/qiniu/logkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/qiniu/logkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/qiniu/logkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/qiniu/logkit/contents/{+path}","compare_url":"https://api.github.com/repos/qiniu/logkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qiniu/logkit/merges","archive_url":"https://api.github.com/repos/qiniu/logkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qiniu/logkit/downloads","issues_url":"https://api.github.com/repos/qiniu/logkit/issues{/number}","pulls_url":"https://api.github.com/repos/qiniu/logkit/pulls{/number}","milestones_url":"https://api.github.com/repos/qiniu/logkit/milestones{/number}","notifications_url":"https://api.github.com/repos/qiniu/logkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qiniu/logkit/labels{/name}","releases_url":"https://api.github.com/repos/qiniu/logkit/releases{/id}","deployments_url":"https://api.github.com/repos/qiniu/logkit/deployments","created_at":"2017-05-15T06:50:40Z","updated_at":"2018-11-05T10:02:28Z","pushed_at":"2018-11-06T02:08:05Z","git_url":"git://github.com/qiniu/logkit.git","ssh_url":"git@github.com:qiniu/logkit.git","clone_url":"https://github.com/qiniu/logkit.git","svn_url":"https://github.com/qiniu/logkit","homepage":"https://logkit-pro.qiniu.com","size":21099,"stargazers_count":663,"watchers_count":663,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":141,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":141,"open_issues":11,"watchers":663,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/qiniu/logkit/pulls/808"},"html":{"href":"https://github.com/qiniu/logkit/pull/808"},"issue":{"href":"https://api.github.com/repos/qiniu/logkit/issues/808"},"comments":{"href":"https://api.github.com/repos/qiniu/logkit/issues/808/comments"},"review_comments":{"href":"https://api.github.com/repos/qiniu/logkit/pulls/808/comments"},"review_comment":{"href":"https://api.github.com/repos/qiniu/logkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/qiniu/logkit/pulls/808/commits"},"statuses":{"href":"https://api.github.com/repos/qiniu/logkit/statuses/b73f886c3730aca7d0fbafb31e6d22fa162adc9a"}},"author_association":"NONE"}}
{"actor":{"display_login":"wonderflow"}}