{"action":"created","comment":{"url":"https://api.github.com/repos/stripe/veneur/pulls/comments/95257033","pull_request_review_id":15805255,"id":95257033,"diff_hunk":"@@ -0,0 +1,142 @@\n+package influxdb\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\t\"net/http\"\n+\t\"net/url\"\n+\t\"regexp\"\n+\t\"strings\"\n+\t\"time\"\n+\n+\t\"github.com/DataDog/datadog-go/statsd\"\n+\t\"github.com/Sirupsen/logrus\"\n+\t\"github.com/stripe/veneur/plugins\"\n+\t\"github.com/stripe/veneur/samplers\"\n+)\n+\n+var _ plugins.Plugin = &InfluxDBPlugin{}\n+\n+// InfluxDBPlugin is a plugin for emitting metrics to InfluxDB.\n+type InfluxDBPlugin struct {\n+\tLogger     *logrus.Logger\n+\tInfluxURL  string\n+\tHTTPClient *http.Client\n+\tStatsd     *statsd.Client\n+}\n+\n+// NewInfluxDBPlugin creates a new Influx Plugin.\n+func NewInfluxDBPlugin(logger *logrus.Logger, addr string, consistency string, db string, client *http.Client, stats *statsd.Client) *InfluxDBPlugin {\n+\tplugin := &InfluxDBPlugin{\n+\t\tLogger:     logger,\n+\t\tHTTPClient: client,\n+\t\tStatsd:     stats,\n+\t}\n+\n+\tinurl, err := url.Parse(addr)\n+\tif err != nil {\n+\t\tlogger.Fatalf(\"Error parsing URL for InfluxDB: %q\", err)\n+\t}\n+\n+\t// Construct a path we will be using later.\n+\tinurl.Path = \"/write\"\n+\tq := inurl.Query()\n+\tq.Set(\"db\", db)\n+\tq.Set(\"precision\", \"s\")\n+\tinurl.RawQuery = q.Encode()\n+\tplugin.InfluxURL = inurl.String()\n+\n+\treturn plugin\n+}\n+\n+// Flush sends a slice of metrics to InfluxDB\n+func (p *InfluxDBPlugin) Flush(metrics []samplers.DDMetric, hostname string) error {\n+\tp.Statsd.Gauge(\"flush.post_metrics_total\", float64(len(metrics)), nil, 1.0)\n+\t// Check to see if we have anything to do\n+\tif len(metrics) == 0 {\n+\t\tp.Logger.Info(\"Nothing to flush, skipping.\")\n+\t\treturn nil\n+\t}\n+\n+\tbuff := bytes.Buffer{}","path":"plugins/influxdb/influxdb.go","position":62,"original_position":62,"commit_id":"658982b5f5c8ad636a2c139625cf71a1dcbe631c","original_commit_id":"658982b5f5c8ad636a2c139625cf71a1dcbe631c","user":{"login":"ChimeraCoder","id":376414,"avatar_url":"https://avatars.githubusercontent.com/u/376414?v=3","gravatar_id":"","url":"https://api.github.com/users/ChimeraCoder","html_url":"https://github.com/ChimeraCoder","followers_url":"https://api.github.com/users/ChimeraCoder/followers","following_url":"https://api.github.com/users/ChimeraCoder/following{/other_user}","gists_url":"https://api.github.com/users/ChimeraCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/ChimeraCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChimeraCoder/subscriptions","organizations_url":"https://api.github.com/users/ChimeraCoder/orgs","repos_url":"https://api.github.com/users/ChimeraCoder/repos","events_url":"https://api.github.com/users/ChimeraCoder/events{/privacy}","received_events_url":"https://api.github.com/users/ChimeraCoder/received_events","type":"User","site_admin":false},"body":"Though actually, since we're only writing to it once, we should probably use `strings.Reader`. e.g.\r\n\r\n```go\r\nvar buff *strings.Reader\r\nfor _, metric := range metrics {\r\n    ...\r\n    buff = strings.NewReader(...)\r\n}\r\n```\r\n\r\nbecause, among other things, that'll allow us to accept an `io.Reader` for the `postHelper` function (see my next comment)","created_at":"2017-01-09T22:04:08Z","updated_at":"2017-01-09T22:12:36Z","html_url":"https://github.com/stripe/veneur/pull/114#discussion_r95257033","pull_request_url":"https://api.github.com/repos/stripe/veneur/pulls/114","_links":{"self":{"href":"https://api.github.com/repos/stripe/veneur/pulls/comments/95257033"},"html":{"href":"https://github.com/stripe/veneur/pull/114#discussion_r95257033"},"pull_request":{"href":"https://api.github.com/repos/stripe/veneur/pulls/114"}}},"pull_request":{"url":"https://api.github.com/repos/stripe/veneur/pulls/114","id":99314973,"html_url":"https://github.com/stripe/veneur/pull/114","diff_url":"https://github.com/stripe/veneur/pull/114.diff","patch_url":"https://github.com/stripe/veneur/pull/114.patch","issue_url":"https://api.github.com/repos/stripe/veneur/issues/114","number":114,"state":"open","locked":false,"title":"Add influxdb plugin","user":{"login":"gphat","id":45159,"avatar_url":"https://avatars.githubusercontent.com/u/45159?v=3","gravatar_id":"","url":"https://api.github.com/users/gphat","html_url":"https://github.com/gphat","followers_url":"https://api.github.com/users/gphat/followers","following_url":"https://api.github.com/users/gphat/following{/other_user}","gists_url":"https://api.github.com/users/gphat/gists{/gist_id}","starred_url":"https://api.github.com/users/gphat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gphat/subscriptions","organizations_url":"https://api.github.com/users/gphat/orgs","repos_url":"https://api.github.com/users/gphat/repos","events_url":"https://api.github.com/users/gphat/events{/privacy}","received_events_url":"https://api.github.com/users/gphat/received_events","type":"User","site_admin":false},"body":"#### Summary\r\nAdds InfluxDB plugin.\r\n\r\n\r\n#### Motivation\r\nTo write to InfluxDB! Note that this probably isn't how we actually want to do it because we should probably plugin Datadog first, but it's a start!\r\n\r\n#### Test plan\r\nUntested so far, kinda a WIP.","created_at":"2016-12-25T03:25:15Z","updated_at":"2017-01-09T22:12:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c68843095080b04aca7fc54911810642f0b0aa9e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/stripe/veneur/pulls/114/commits","review_comments_url":"https://api.github.com/repos/stripe/veneur/pulls/114/comments","review_comment_url":"https://api.github.com/repos/stripe/veneur/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stripe/veneur/issues/114/comments","statuses_url":"https://api.github.com/repos/stripe/veneur/statuses/658982b5f5c8ad636a2c139625cf71a1dcbe631c","head":{"label":"gphat:cory-influxdb","ref":"cory-influxdb","sha":"658982b5f5c8ad636a2c139625cf71a1dcbe631c","user":{"login":"gphat","id":45159,"avatar_url":"https://avatars.githubusercontent.com/u/45159?v=3","gravatar_id":"","url":"https://api.github.com/users/gphat","html_url":"https://github.com/gphat","followers_url":"https://api.github.com/users/gphat/followers","following_url":"https://api.github.com/users/gphat/following{/other_user}","gists_url":"https://api.github.com/users/gphat/gists{/gist_id}","starred_url":"https://api.github.com/users/gphat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gphat/subscriptions","organizations_url":"https://api.github.com/users/gphat/orgs","repos_url":"https://api.github.com/users/gphat/repos","events_url":"https://api.github.com/users/gphat/events{/privacy}","received_events_url":"https://api.github.com/users/gphat/received_events","type":"User","site_admin":false},"repo":{"id":77301983,"name":"veneur","full_name":"gphat/veneur","owner":{"login":"gphat","id":45159,"avatar_url":"https://avatars.githubusercontent.com/u/45159?v=3","gravatar_id":"","url":"https://api.github.com/users/gphat","html_url":"https://github.com/gphat","followers_url":"https://api.github.com/users/gphat/followers","following_url":"https://api.github.com/users/gphat/following{/other_user}","gists_url":"https://api.github.com/users/gphat/gists{/gist_id}","starred_url":"https://api.github.com/users/gphat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gphat/subscriptions","organizations_url":"https://api.github.com/users/gphat/orgs","repos_url":"https://api.github.com/users/gphat/repos","events_url":"https://api.github.com/users/gphat/events{/privacy}","received_events_url":"https://api.github.com/users/gphat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gphat/veneur","description":"A DogStatsD server implementation with global aggregation capability.","fork":true,"url":"https://api.github.com/repos/gphat/veneur","forks_url":"https://api.github.com/repos/gphat/veneur/forks","keys_url":"https://api.github.com/repos/gphat/veneur/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gphat/veneur/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gphat/veneur/teams","hooks_url":"https://api.github.com/repos/gphat/veneur/hooks","issue_events_url":"https://api.github.com/repos/gphat/veneur/issues/events{/number}","events_url":"https://api.github.com/repos/gphat/veneur/events","assignees_url":"https://api.github.com/repos/gphat/veneur/assignees{/user}","branches_url":"https://api.github.com/repos/gphat/veneur/branches{/branch}","tags_url":"https://api.github.com/repos/gphat/veneur/tags","blobs_url":"https://api.github.com/repos/gphat/veneur/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gphat/veneur/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gphat/veneur/git/refs{/sha}","trees_url":"https://api.github.com/repos/gphat/veneur/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gphat/veneur/statuses/{sha}","languages_url":"https://api.github.com/repos/gphat/veneur/languages","stargazers_url":"https://api.github.com/repos/gphat/veneur/stargazers","contributors_url":"https://api.github.com/repos/gphat/veneur/contributors","subscribers_url":"https://api.github.com/repos/gphat/veneur/subscribers","subscription_url":"https://api.github.com/repos/gphat/veneur/subscription","commits_url":"https://api.github.com/repos/gphat/veneur/commits{/sha}","git_commits_url":"https://api.github.com/repos/gphat/veneur/git/commits{/sha}","comments_url":"https://api.github.com/repos/gphat/veneur/comments{/number}","issue_comment_url":"https://api.github.com/repos/gphat/veneur/issues/comments{/number}","contents_url":"https://api.github.com/repos/gphat/veneur/contents/{+path}","compare_url":"https://api.github.com/repos/gphat/veneur/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gphat/veneur/merges","archive_url":"https://api.github.com/repos/gphat/veneur/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gphat/veneur/downloads","issues_url":"https://api.github.com/repos/gphat/veneur/issues{/number}","pulls_url":"https://api.github.com/repos/gphat/veneur/pulls{/number}","milestones_url":"https://api.github.com/repos/gphat/veneur/milestones{/number}","notifications_url":"https://api.github.com/repos/gphat/veneur/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gphat/veneur/labels{/name}","releases_url":"https://api.github.com/repos/gphat/veneur/releases{/id}","deployments_url":"https://api.github.com/repos/gphat/veneur/deployments","created_at":"2016-12-24T22:20:15Z","updated_at":"2016-12-24T22:20:18Z","pushed_at":"2017-01-09T21:35:48Z","git_url":"git://github.com/gphat/veneur.git","ssh_url":"git@github.com:gphat/veneur.git","clone_url":"https://github.com/gphat/veneur.git","svn_url":"https://github.com/gphat/veneur","homepage":"","size":2075,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"stripe:master","ref":"master","sha":"2f23c4e8450c47724c43cb10802e716837256bde","user":{"login":"stripe","id":856813,"avatar_url":"https://avatars.githubusercontent.com/u/856813?v=3","gravatar_id":"","url":"https://api.github.com/users/stripe","html_url":"https://github.com/stripe","followers_url":"https://api.github.com/users/stripe/followers","following_url":"https://api.github.com/users/stripe/following{/other_user}","gists_url":"https://api.github.com/users/stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stripe/subscriptions","organizations_url":"https://api.github.com/users/stripe/orgs","repos_url":"https://api.github.com/users/stripe/repos","events_url":"https://api.github.com/users/stripe/events{/privacy}","received_events_url":"https://api.github.com/users/stripe/received_events","type":"Organization","site_admin":false},"repo":{"id":55277533,"name":"veneur","full_name":"stripe/veneur","owner":{"login":"stripe","id":856813,"avatar_url":"https://avatars.githubusercontent.com/u/856813?v=3","gravatar_id":"","url":"https://api.github.com/users/stripe","html_url":"https://github.com/stripe","followers_url":"https://api.github.com/users/stripe/followers","following_url":"https://api.github.com/users/stripe/following{/other_user}","gists_url":"https://api.github.com/users/stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stripe/subscriptions","organizations_url":"https://api.github.com/users/stripe/orgs","repos_url":"https://api.github.com/users/stripe/repos","events_url":"https://api.github.com/users/stripe/events{/privacy}","received_events_url":"https://api.github.com/users/stripe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stripe/veneur","description":"A DogStatsD server implementation with global aggregation capability.","fork":false,"url":"https://api.github.com/repos/stripe/veneur","forks_url":"https://api.github.com/repos/stripe/veneur/forks","keys_url":"https://api.github.com/repos/stripe/veneur/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stripe/veneur/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stripe/veneur/teams","hooks_url":"https://api.github.com/repos/stripe/veneur/hooks","issue_events_url":"https://api.github.com/repos/stripe/veneur/issues/events{/number}","events_url":"https://api.github.com/repos/stripe/veneur/events","assignees_url":"https://api.github.com/repos/stripe/veneur/assignees{/user}","branches_url":"https://api.github.com/repos/stripe/veneur/branches{/branch}","tags_url":"https://api.github.com/repos/stripe/veneur/tags","blobs_url":"https://api.github.com/repos/stripe/veneur/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stripe/veneur/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stripe/veneur/git/refs{/sha}","trees_url":"https://api.github.com/repos/stripe/veneur/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stripe/veneur/statuses/{sha}","languages_url":"https://api.github.com/repos/stripe/veneur/languages","stargazers_url":"https://api.github.com/repos/stripe/veneur/stargazers","contributors_url":"https://api.github.com/repos/stripe/veneur/contributors","subscribers_url":"https://api.github.com/repos/stripe/veneur/subscribers","subscription_url":"https://api.github.com/repos/stripe/veneur/subscription","commits_url":"https://api.github.com/repos/stripe/veneur/commits{/sha}","git_commits_url":"https://api.github.com/repos/stripe/veneur/git/commits{/sha}","comments_url":"https://api.github.com/repos/stripe/veneur/comments{/number}","issue_comment_url":"https://api.github.com/repos/stripe/veneur/issues/comments{/number}","contents_url":"https://api.github.com/repos/stripe/veneur/contents/{+path}","compare_url":"https://api.github.com/repos/stripe/veneur/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stripe/veneur/merges","archive_url":"https://api.github.com/repos/stripe/veneur/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stripe/veneur/downloads","issues_url":"https://api.github.com/repos/stripe/veneur/issues{/number}","pulls_url":"https://api.github.com/repos/stripe/veneur/pulls{/number}","milestones_url":"https://api.github.com/repos/stripe/veneur/milestones{/number}","notifications_url":"https://api.github.com/repos/stripe/veneur/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stripe/veneur/labels{/name}","releases_url":"https://api.github.com/repos/stripe/veneur/releases{/id}","deployments_url":"https://api.github.com/repos/stripe/veneur/deployments","created_at":"2016-04-02T04:24:34Z","updated_at":"2017-01-09T07:06:14Z","pushed_at":"2017-01-09T21:35:49Z","git_url":"git://github.com/stripe/veneur.git","ssh_url":"git@github.com:stripe/veneur.git","clone_url":"https://github.com/stripe/veneur.git","svn_url":"https://github.com/stripe/veneur","homepage":"","size":2086,"stargazers_count":187,"watchers_count":187,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":7,"forks":8,"open_issues":7,"watchers":187,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stripe/veneur/pulls/114"},"html":{"href":"https://github.com/stripe/veneur/pull/114"},"issue":{"href":"https://api.github.com/repos/stripe/veneur/issues/114"},"comments":{"href":"https://api.github.com/repos/stripe/veneur/issues/114/comments"},"review_comments":{"href":"https://api.github.com/repos/stripe/veneur/pulls/114/comments"},"review_comment":{"href":"https://api.github.com/repos/stripe/veneur/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stripe/veneur/pulls/114/commits"},"statuses":{"href":"https://api.github.com/repos/stripe/veneur/statuses/658982b5f5c8ad636a2c139625cf71a1dcbe631c"}}}}
{"actor":{"display_login":"ChimeraCoder"}}