{"action":"created","comment":{"url":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/comments/204604101","pull_request_review_id":139618210,"id":204604101,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDYwNDEwMQ==","diff_hunk":"@@ -0,0 +1,102 @@\n+package graphite_client\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"net\"\n+\t\"time\"\n+)\n+\n+// Graphite is a struct that defines the relevant properties of a graphite\n+// connection\n+type Graphite struct {\n+\tHost     string\n+\tPort     int\n+\tTimeout  time.Duration\n+\tconn     net.Conn\n+}\n+\n+// defaultTimeout is the default number of seconds that we're willing to wait\n+// before forcing the connection establishment to fail\n+const defaultTimeout = 5\n+\n+// Given a Graphite struct, Connect populates the Graphite.conn field with an\n+// appropriate TCP connection\n+func (graphite *Graphite) Connect() error {\n+\tif graphite.conn != nil {\n+\t\tgraphite.conn.Close()\n+\t}\n+\n+\taddress := fmt.Sprintf(\"%s:%d\", graphite.Host, graphite.Port)\n+\n+\tif graphite.Timeout == 0 {\n+\t\tgraphite.Timeout = defaultTimeout * time.Second\n+\t}\n+\n+\tvar err error\n+\tvar conn net.Conn\n+\n+\tconn, err = net.DialTimeout(\"tcp\", address, graphite.Timeout)\n+\n+\tgraphite.conn = conn\n+\n+\treturn err\n+}\n+\n+// Given a Graphite struct, Disconnect closes the Graphite.conn field\n+func (graphite *Graphite) Disconnect() error {\n+\terr := graphite.conn.Close()\n+\tgraphite.conn = nil\n+\treturn err\n+}\n+\n+// sendMetrics is an internal function that is used to write to the TCP\n+// connection in order to communicate metrics to the remote Graphite host\n+func (graphite *Graphite) sendMetrics(metrics []Metric) error {\n+\tzeroedMetric := Metric{}\n+\tbuf := bytes.NewBufferString(\"\")\n+\tfor _, metric := range metrics {\n+\t\tif metric == zeroedMetric {\n+\t\t\tcontinue\n+\t\t}\n+\t\tif metric.Timestamp == 0 {\n+\t\t\tmetric.Timestamp = time.Now().Unix()\n+\t\t}\n+\t\tmetricName := metric.Name\n+\t\tbuf.WriteString(fmt.Sprintf(\"%s %s %d\\n\", metricName, metric.Value, metric.Timestamp))\n+\t}\n+\t_, err := graphite.conn.Write(buf.Bytes())\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\treturn nil\n+}\n+\n+// The SendMetric method can be used to just pass a metric name and value and\n+// have it be sent to the Graphite host\n+func (graphite *Graphite) SendMetric(stat string, value string, timestamp int64) error {\n+\tmetrics := make([]Metric, 1)\n+\tmetrics[0] = NewMetric(stat, value, timestamp)\n+\terr := graphite.sendMetrics(metrics)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\treturn nil\n+}\n+\n+// NewGraphite is a factory method that's used to create a new Graphite\n+func NewGraphite(host string, port int) (*Graphite, error) {\n+\treturn GraphiteFactory(host, port)\n+}\n+\n+func GraphiteFactory(host string, port int) (*Graphite, error) {","path":"exporter/graphite/client/client.go","position":92,"original_position":92,"commit_id":"7470667e92a0c275f5dd9b16085c590eaa907f85","original_commit_id":"7470667e92a0c275f5dd9b16085c590eaa907f85","user":{"login":"ramonza","id":349160,"node_id":"MDQ6VXNlcjM0OTE2MA==","avatar_url":"https://avatars2.githubusercontent.com/u/349160?v=4","gravatar_id":"","url":"https://api.github.com/users/ramonza","html_url":"https://github.com/ramonza","followers_url":"https://api.github.com/users/ramonza/followers","following_url":"https://api.github.com/users/ramonza/following{/other_user}","gists_url":"https://api.github.com/users/ramonza/gists{/gist_id}","starred_url":"https://api.github.com/users/ramonza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramonza/subscriptions","organizations_url":"https://api.github.com/users/ramonza/orgs","repos_url":"https://api.github.com/users/ramonza/repos","events_url":"https://api.github.com/users/ramonza/events{/privacy}","received_events_url":"https://api.github.com/users/ramonza/received_events","type":"User","site_admin":false},"body":"Factory is not a common idiom in Go, rather just use the New method above.","created_at":"2018-07-24T02:00:11Z","updated_at":"2018-07-24T02:07:40Z","html_url":"https://github.com/CESARBR/opencensus-go/pull/2#discussion_r204604101","pull_request_url":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/2","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/comments/204604101"},"html":{"href":"https://github.com/CESARBR/opencensus-go/pull/2#discussion_r204604101"},"pull_request":{"href":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/2","id":202308354,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyMzA4MzU0","html_url":"https://github.com/CESARBR/opencensus-go/pull/2","diff_url":"https://github.com/CESARBR/opencensus-go/pull/2.diff","patch_url":"https://github.com/CESARBR/opencensus-go/pull/2.patch","issue_url":"https://api.github.com/repos/CESARBR/opencensus-go/issues/2","number":2,"state":"open","locked":false,"title":"Graphite exporter","user":{"login":"vcasadei","id":1724240,"node_id":"MDQ6VXNlcjE3MjQyNDA=","avatar_url":"https://avatars1.githubusercontent.com/u/1724240?v=4","gravatar_id":"","url":"https://api.github.com/users/vcasadei","html_url":"https://github.com/vcasadei","followers_url":"https://api.github.com/users/vcasadei/followers","following_url":"https://api.github.com/users/vcasadei/following{/other_user}","gists_url":"https://api.github.com/users/vcasadei/gists{/gist_id}","starred_url":"https://api.github.com/users/vcasadei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vcasadei/subscriptions","organizations_url":"https://api.github.com/users/vcasadei/orgs","repos_url":"https://api.github.com/users/vcasadei/repos","events_url":"https://api.github.com/users/vcasadei/events{/privacy}","received_events_url":"https://api.github.com/users/vcasadei/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-18T16:19:08Z","updated_at":"2018-07-24T02:07:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"85a8fe67736adbd2bd936497814bcaf761fad01d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"maurojcs","id":12688368,"node_id":"MDQ6VXNlcjEyNjg4MzY4","avatar_url":"https://avatars1.githubusercontent.com/u/12688368?v=4","gravatar_id":"","url":"https://api.github.com/users/maurojcs","html_url":"https://github.com/maurojcs","followers_url":"https://api.github.com/users/maurojcs/followers","following_url":"https://api.github.com/users/maurojcs/following{/other_user}","gists_url":"https://api.github.com/users/maurojcs/gists{/gist_id}","starred_url":"https://api.github.com/users/maurojcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maurojcs/subscriptions","organizations_url":"https://api.github.com/users/maurojcs/orgs","repos_url":"https://api.github.com/users/maurojcs/repos","events_url":"https://api.github.com/users/maurojcs/events{/privacy}","received_events_url":"https://api.github.com/users/maurojcs/received_events","type":"User","site_admin":false},{"login":"MarceloAquino7","id":17485700,"node_id":"MDQ6VXNlcjE3NDg1NzAw","avatar_url":"https://avatars0.githubusercontent.com/u/17485700?v=4","gravatar_id":"","url":"https://api.github.com/users/MarceloAquino7","html_url":"https://github.com/MarceloAquino7","followers_url":"https://api.github.com/users/MarceloAquino7/followers","following_url":"https://api.github.com/users/MarceloAquino7/following{/other_user}","gists_url":"https://api.github.com/users/MarceloAquino7/gists{/gist_id}","starred_url":"https://api.github.com/users/MarceloAquino7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarceloAquino7/subscriptions","organizations_url":"https://api.github.com/users/MarceloAquino7/orgs","repos_url":"https://api.github.com/users/MarceloAquino7/repos","events_url":"https://api.github.com/users/MarceloAquino7/events{/privacy}","received_events_url":"https://api.github.com/users/MarceloAquino7/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/2/commits","review_comments_url":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/2/comments","review_comment_url":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CESARBR/opencensus-go/issues/2/comments","statuses_url":"https://api.github.com/repos/CESARBR/opencensus-go/statuses/7470667e92a0c275f5dd9b16085c590eaa907f85","head":{"label":"CESARBR:graphite_exporter","ref":"graphite_exporter","sha":"7470667e92a0c275f5dd9b16085c590eaa907f85","user":{"login":"CESARBR","id":7859691,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc4NTk2OTE=","avatar_url":"https://avatars2.githubusercontent.com/u/7859691?v=4","gravatar_id":"","url":"https://api.github.com/users/CESARBR","html_url":"https://github.com/CESARBR","followers_url":"https://api.github.com/users/CESARBR/followers","following_url":"https://api.github.com/users/CESARBR/following{/other_user}","gists_url":"https://api.github.com/users/CESARBR/gists{/gist_id}","starred_url":"https://api.github.com/users/CESARBR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CESARBR/subscriptions","organizations_url":"https://api.github.com/users/CESARBR/orgs","repos_url":"https://api.github.com/users/CESARBR/repos","events_url":"https://api.github.com/users/CESARBR/events{/privacy}","received_events_url":"https://api.github.com/users/CESARBR/received_events","type":"Organization","site_admin":false},"repo":{"id":138773263,"node_id":"MDEwOlJlcG9zaXRvcnkxMzg3NzMyNjM=","name":"opencensus-go","full_name":"CESARBR/opencensus-go","owner":{"login":"CESARBR","id":7859691,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc4NTk2OTE=","avatar_url":"https://avatars2.githubusercontent.com/u/7859691?v=4","gravatar_id":"","url":"https://api.github.com/users/CESARBR","html_url":"https://github.com/CESARBR","followers_url":"https://api.github.com/users/CESARBR/followers","following_url":"https://api.github.com/users/CESARBR/following{/other_user}","gists_url":"https://api.github.com/users/CESARBR/gists{/gist_id}","starred_url":"https://api.github.com/users/CESARBR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CESARBR/subscriptions","organizations_url":"https://api.github.com/users/CESARBR/orgs","repos_url":"https://api.github.com/users/CESARBR/repos","events_url":"https://api.github.com/users/CESARBR/events{/privacy}","received_events_url":"https://api.github.com/users/CESARBR/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CESARBR/opencensus-go","description":"A stats collection and distributed tracing framework","fork":true,"url":"https://api.github.com/repos/CESARBR/opencensus-go","forks_url":"https://api.github.com/repos/CESARBR/opencensus-go/forks","keys_url":"https://api.github.com/repos/CESARBR/opencensus-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CESARBR/opencensus-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CESARBR/opencensus-go/teams","hooks_url":"https://api.github.com/repos/CESARBR/opencensus-go/hooks","issue_events_url":"https://api.github.com/repos/CESARBR/opencensus-go/issues/events{/number}","events_url":"https://api.github.com/repos/CESARBR/opencensus-go/events","assignees_url":"https://api.github.com/repos/CESARBR/opencensus-go/assignees{/user}","branches_url":"https://api.github.com/repos/CESARBR/opencensus-go/branches{/branch}","tags_url":"https://api.github.com/repos/CESARBR/opencensus-go/tags","blobs_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CESARBR/opencensus-go/statuses/{sha}","languages_url":"https://api.github.com/repos/CESARBR/opencensus-go/languages","stargazers_url":"https://api.github.com/repos/CESARBR/opencensus-go/stargazers","contributors_url":"https://api.github.com/repos/CESARBR/opencensus-go/contributors","subscribers_url":"https://api.github.com/repos/CESARBR/opencensus-go/subscribers","subscription_url":"https://api.github.com/repos/CESARBR/opencensus-go/subscription","commits_url":"https://api.github.com/repos/CESARBR/opencensus-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/CESARBR/opencensus-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/CESARBR/opencensus-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/CESARBR/opencensus-go/contents/{+path}","compare_url":"https://api.github.com/repos/CESARBR/opencensus-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CESARBR/opencensus-go/merges","archive_url":"https://api.github.com/repos/CESARBR/opencensus-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CESARBR/opencensus-go/downloads","issues_url":"https://api.github.com/repos/CESARBR/opencensus-go/issues{/number}","pulls_url":"https://api.github.com/repos/CESARBR/opencensus-go/pulls{/number}","milestones_url":"https://api.github.com/repos/CESARBR/opencensus-go/milestones{/number}","notifications_url":"https://api.github.com/repos/CESARBR/opencensus-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CESARBR/opencensus-go/labels{/name}","releases_url":"https://api.github.com/repos/CESARBR/opencensus-go/releases{/id}","deployments_url":"https://api.github.com/repos/CESARBR/opencensus-go/deployments","created_at":"2018-06-26T17:48:39Z","updated_at":"2018-06-26T17:48:41Z","pushed_at":"2018-07-23T11:25:53Z","git_url":"git://github.com/CESARBR/opencensus-go.git","ssh_url":"git@github.com:CESARBR/opencensus-go.git","clone_url":"https://github.com/CESARBR/opencensus-go.git","svn_url":"https://github.com/CESARBR/opencensus-go","homepage":"http://opencensus.io","size":1447,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"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":1,"watchers":0,"default_branch":"master"}},"base":{"label":"CESARBR:master","ref":"master","sha":"140879bf49cb17276aaf28b5f6a04e251ff98473","user":{"login":"CESARBR","id":7859691,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc4NTk2OTE=","avatar_url":"https://avatars2.githubusercontent.com/u/7859691?v=4","gravatar_id":"","url":"https://api.github.com/users/CESARBR","html_url":"https://github.com/CESARBR","followers_url":"https://api.github.com/users/CESARBR/followers","following_url":"https://api.github.com/users/CESARBR/following{/other_user}","gists_url":"https://api.github.com/users/CESARBR/gists{/gist_id}","starred_url":"https://api.github.com/users/CESARBR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CESARBR/subscriptions","organizations_url":"https://api.github.com/users/CESARBR/orgs","repos_url":"https://api.github.com/users/CESARBR/repos","events_url":"https://api.github.com/users/CESARBR/events{/privacy}","received_events_url":"https://api.github.com/users/CESARBR/received_events","type":"Organization","site_admin":false},"repo":{"id":138773263,"node_id":"MDEwOlJlcG9zaXRvcnkxMzg3NzMyNjM=","name":"opencensus-go","full_name":"CESARBR/opencensus-go","owner":{"login":"CESARBR","id":7859691,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc4NTk2OTE=","avatar_url":"https://avatars2.githubusercontent.com/u/7859691?v=4","gravatar_id":"","url":"https://api.github.com/users/CESARBR","html_url":"https://github.com/CESARBR","followers_url":"https://api.github.com/users/CESARBR/followers","following_url":"https://api.github.com/users/CESARBR/following{/other_user}","gists_url":"https://api.github.com/users/CESARBR/gists{/gist_id}","starred_url":"https://api.github.com/users/CESARBR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CESARBR/subscriptions","organizations_url":"https://api.github.com/users/CESARBR/orgs","repos_url":"https://api.github.com/users/CESARBR/repos","events_url":"https://api.github.com/users/CESARBR/events{/privacy}","received_events_url":"https://api.github.com/users/CESARBR/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CESARBR/opencensus-go","description":"A stats collection and distributed tracing framework","fork":true,"url":"https://api.github.com/repos/CESARBR/opencensus-go","forks_url":"https://api.github.com/repos/CESARBR/opencensus-go/forks","keys_url":"https://api.github.com/repos/CESARBR/opencensus-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CESARBR/opencensus-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CESARBR/opencensus-go/teams","hooks_url":"https://api.github.com/repos/CESARBR/opencensus-go/hooks","issue_events_url":"https://api.github.com/repos/CESARBR/opencensus-go/issues/events{/number}","events_url":"https://api.github.com/repos/CESARBR/opencensus-go/events","assignees_url":"https://api.github.com/repos/CESARBR/opencensus-go/assignees{/user}","branches_url":"https://api.github.com/repos/CESARBR/opencensus-go/branches{/branch}","tags_url":"https://api.github.com/repos/CESARBR/opencensus-go/tags","blobs_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CESARBR/opencensus-go/statuses/{sha}","languages_url":"https://api.github.com/repos/CESARBR/opencensus-go/languages","stargazers_url":"https://api.github.com/repos/CESARBR/opencensus-go/stargazers","contributors_url":"https://api.github.com/repos/CESARBR/opencensus-go/contributors","subscribers_url":"https://api.github.com/repos/CESARBR/opencensus-go/subscribers","subscription_url":"https://api.github.com/repos/CESARBR/opencensus-go/subscription","commits_url":"https://api.github.com/repos/CESARBR/opencensus-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/CESARBR/opencensus-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/CESARBR/opencensus-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/CESARBR/opencensus-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/CESARBR/opencensus-go/contents/{+path}","compare_url":"https://api.github.com/repos/CESARBR/opencensus-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CESARBR/opencensus-go/merges","archive_url":"https://api.github.com/repos/CESARBR/opencensus-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CESARBR/opencensus-go/downloads","issues_url":"https://api.github.com/repos/CESARBR/opencensus-go/issues{/number}","pulls_url":"https://api.github.com/repos/CESARBR/opencensus-go/pulls{/number}","milestones_url":"https://api.github.com/repos/CESARBR/opencensus-go/milestones{/number}","notifications_url":"https://api.github.com/repos/CESARBR/opencensus-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CESARBR/opencensus-go/labels{/name}","releases_url":"https://api.github.com/repos/CESARBR/opencensus-go/releases{/id}","deployments_url":"https://api.github.com/repos/CESARBR/opencensus-go/deployments","created_at":"2018-06-26T17:48:39Z","updated_at":"2018-06-26T17:48:41Z","pushed_at":"2018-07-23T11:25:53Z","git_url":"git://github.com/CESARBR/opencensus-go.git","ssh_url":"git@github.com:CESARBR/opencensus-go.git","clone_url":"https://github.com/CESARBR/opencensus-go.git","svn_url":"https://github.com/CESARBR/opencensus-go","homepage":"http://opencensus.io","size":1447,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"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":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/2"},"html":{"href":"https://github.com/CESARBR/opencensus-go/pull/2"},"issue":{"href":"https://api.github.com/repos/CESARBR/opencensus-go/issues/2"},"comments":{"href":"https://api.github.com/repos/CESARBR/opencensus-go/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CESARBR/opencensus-go/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/CESARBR/opencensus-go/statuses/7470667e92a0c275f5dd9b16085c590eaa907f85"}},"author_association":"NONE"}}
{"actor":{"display_login":"ramonza"}}