{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/comments/78389578","id":78389578,"diff_hunk":"@@ -53,19 +101,44 @@ func (pc *podCollector) Collect(ch chan<- prometheus.Metric) {\n \t\treturn\n \t}\n \tfor _, p := range pods {\n-\t\tfor _, m := range pc.collectPod(p) {\n-\t\t\tch <- m\n-\t\t}\n+\t\tpc.collectPod(ch, p)\n \t}\n }\n \n-func (pc *podCollector) collectPod(p *api.Pod) (res []prometheus.Metric) {\n-\tfor _, cs := range p.Status.ContainerStatuses {\n-\t\tres = append(res, prometheus.MustNewConstMetric(\n-\t\t\tdescContainerRestarts, prometheus.CounterValue, float64(cs.RestartCount),\n-\t\t\tp.Namespace, p.Name, cs.Name,\n-\t\t))\n+func (pc *podCollector) collectPod(ch chan<- prometheus.Metric, p *api.Pod) {\n+\taddConstMetric := func(desc *prometheus.Desc, t prometheus.ValueType, v float64, lv ...string) {\n+\t\tlv = append([]string{p.Namespace, p.Name}, lv...)\n+\t\tch <- prometheus.MustNewConstMetric(desc, t, v, lv...)\n+\t}\n+\taddGauge := func(desc *prometheus.Desc, v float64, lv ...string) {\n+\t\taddConstMetric(desc, prometheus.GaugeValue, v, lv...)\n+\t}\n+\taddCounter := func(desc *prometheus.Desc, v float64, lv ...string) {\n+\t\taddConstMetric(desc, prometheus.CounterValue, v, lv...)\n+\t}\n+\n+\taddGauge(descPodInfo, 1,\n+\t\tp.Status.HostIP,\n+\t\tp.Status.PodIP,\n+\t)","path":"pod.go","position":100,"original_position":100,"commit_id":"cb047f90d0e9b0e244584515622974bccf9ca5c7","original_commit_id":"cb047f90d0e9b0e244584515622974bccf9ca5c7","user":{"login":"fabxc","id":4948210,"avatar_url":"https://avatars.githubusercontent.com/u/4948210?v=3","gravatar_id":"","url":"https://api.github.com/users/fabxc","html_url":"https://github.com/fabxc","followers_url":"https://api.github.com/users/fabxc/followers","following_url":"https://api.github.com/users/fabxc/following{/other_user}","gists_url":"https://api.github.com/users/fabxc/gists{/gist_id}","starred_url":"https://api.github.com/users/fabxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabxc/subscriptions","organizations_url":"https://api.github.com/users/fabxc/orgs","repos_url":"https://api.github.com/users/fabxc/repos","events_url":"https://api.github.com/users/fabxc/events{/privacy}","received_events_url":"https://api.github.com/users/fabxc/received_events","type":"User","site_admin":false},"body":"Short enough to keep in a single line I think.","created_at":"2016-09-12T15:00:27Z","updated_at":"2016-09-12T15:00:27Z","html_url":"https://github.com/kubernetes/kube-state-metrics/pull/13#discussion_r78389578","pull_request_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/comments/78389578"},"html":{"href":"https://github.com/kubernetes/kube-state-metrics/pull/13#discussion_r78389578"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/13","id":84882453,"html_url":"https://github.com/kubernetes/kube-state-metrics/pull/13","diff_url":"https://github.com/kubernetes/kube-state-metrics/pull/13.diff","patch_url":"https://github.com/kubernetes/kube-state-metrics/pull/13.patch","issue_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/issues/13","number":13,"state":"open","locked":false,"title":"add more pod metrics","user":{"login":"brancz","id":4546722,"avatar_url":"https://avatars.githubusercontent.com/u/4546722?v=3","gravatar_id":"","url":"https://api.github.com/users/brancz","html_url":"https://github.com/brancz","followers_url":"https://api.github.com/users/brancz/followers","following_url":"https://api.github.com/users/brancz/following{/other_user}","gists_url":"https://api.github.com/users/brancz/gists{/gist_id}","starred_url":"https://api.github.com/users/brancz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brancz/subscriptions","organizations_url":"https://api.github.com/users/brancz/orgs","repos_url":"https://api.github.com/users/brancz/repos","events_url":"https://api.github.com/users/brancz/events{/privacy}","received_events_url":"https://api.github.com/users/brancz/received_events","type":"User","site_admin":false},"body":"@fabxc","created_at":"2016-09-12T14:35:00Z","updated_at":"2016-09-12T15:00:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"290dbccee04032fb17f4c168b97e0c18c6555816","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/13/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/13/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/issues/13/comments","statuses_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/statuses/cb047f90d0e9b0e244584515622974bccf9ca5c7","head":{"label":"brancz:pod-metrics","ref":"pod-metrics","sha":"cb047f90d0e9b0e244584515622974bccf9ca5c7","user":{"login":"brancz","id":4546722,"avatar_url":"https://avatars.githubusercontent.com/u/4546722?v=3","gravatar_id":"","url":"https://api.github.com/users/brancz","html_url":"https://github.com/brancz","followers_url":"https://api.github.com/users/brancz/followers","following_url":"https://api.github.com/users/brancz/following{/other_user}","gists_url":"https://api.github.com/users/brancz/gists{/gist_id}","starred_url":"https://api.github.com/users/brancz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brancz/subscriptions","organizations_url":"https://api.github.com/users/brancz/orgs","repos_url":"https://api.github.com/users/brancz/repos","events_url":"https://api.github.com/users/brancz/events{/privacy}","received_events_url":"https://api.github.com/users/brancz/received_events","type":"User","site_admin":false},"repo":{"id":67422303,"name":"kube-state-metrics","full_name":"brancz/kube-state-metrics","owner":{"login":"brancz","id":4546722,"avatar_url":"https://avatars.githubusercontent.com/u/4546722?v=3","gravatar_id":"","url":"https://api.github.com/users/brancz","html_url":"https://github.com/brancz","followers_url":"https://api.github.com/users/brancz/followers","following_url":"https://api.github.com/users/brancz/following{/other_user}","gists_url":"https://api.github.com/users/brancz/gists{/gist_id}","starred_url":"https://api.github.com/users/brancz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brancz/subscriptions","organizations_url":"https://api.github.com/users/brancz/orgs","repos_url":"https://api.github.com/users/brancz/repos","events_url":"https://api.github.com/users/brancz/events{/privacy}","received_events_url":"https://api.github.com/users/brancz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brancz/kube-state-metrics","description":"Add-on agent to generate and expose cluster-level metrics.","fork":true,"url":"https://api.github.com/repos/brancz/kube-state-metrics","forks_url":"https://api.github.com/repos/brancz/kube-state-metrics/forks","keys_url":"https://api.github.com/repos/brancz/kube-state-metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brancz/kube-state-metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brancz/kube-state-metrics/teams","hooks_url":"https://api.github.com/repos/brancz/kube-state-metrics/hooks","issue_events_url":"https://api.github.com/repos/brancz/kube-state-metrics/issues/events{/number}","events_url":"https://api.github.com/repos/brancz/kube-state-metrics/events","assignees_url":"https://api.github.com/repos/brancz/kube-state-metrics/assignees{/user}","branches_url":"https://api.github.com/repos/brancz/kube-state-metrics/branches{/branch}","tags_url":"https://api.github.com/repos/brancz/kube-state-metrics/tags","blobs_url":"https://api.github.com/repos/brancz/kube-state-metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brancz/kube-state-metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brancz/kube-state-metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/brancz/kube-state-metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brancz/kube-state-metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/brancz/kube-state-metrics/languages","stargazers_url":"https://api.github.com/repos/brancz/kube-state-metrics/stargazers","contributors_url":"https://api.github.com/repos/brancz/kube-state-metrics/contributors","subscribers_url":"https://api.github.com/repos/brancz/kube-state-metrics/subscribers","subscription_url":"https://api.github.com/repos/brancz/kube-state-metrics/subscription","commits_url":"https://api.github.com/repos/brancz/kube-state-metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/brancz/kube-state-metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/brancz/kube-state-metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/brancz/kube-state-metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/brancz/kube-state-metrics/contents/{+path}","compare_url":"https://api.github.com/repos/brancz/kube-state-metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brancz/kube-state-metrics/merges","archive_url":"https://api.github.com/repos/brancz/kube-state-metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brancz/kube-state-metrics/downloads","issues_url":"https://api.github.com/repos/brancz/kube-state-metrics/issues{/number}","pulls_url":"https://api.github.com/repos/brancz/kube-state-metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/brancz/kube-state-metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/brancz/kube-state-metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brancz/kube-state-metrics/labels{/name}","releases_url":"https://api.github.com/repos/brancz/kube-state-metrics/releases{/id}","deployments_url":"https://api.github.com/repos/brancz/kube-state-metrics/deployments","created_at":"2016-09-05T13:14:35Z","updated_at":"2016-09-05T13:14:36Z","pushed_at":"2016-09-12T14:34:22Z","git_url":"git://github.com/brancz/kube-state-metrics.git","ssh_url":"git@github.com:brancz/kube-state-metrics.git","clone_url":"https://github.com/brancz/kube-state-metrics.git","svn_url":"https://github.com/brancz/kube-state-metrics","homepage":"","size":1872,"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":"kubernetes:master","ref":"master","sha":"bbd9bdc5a4faefd4a69fd7099e3d0b65c309daa9","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":58184885,"name":"kube-state-metrics","full_name":"kubernetes/kube-state-metrics","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/kube-state-metrics","description":"Add-on agent to generate and expose cluster-level metrics.","fork":false,"url":"https://api.github.com/repos/kubernetes/kube-state-metrics","forks_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/forks","keys_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/teams","hooks_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/events","assignees_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/tags","blobs_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/languages","stargazers_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/subscription","commits_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/merges","archive_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/downloads","issues_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/releases{/id}","deployments_url":"https://api.github.com/repos/kubernetes/kube-state-metrics/deployments","created_at":"2016-05-06T06:10:13Z","updated_at":"2016-09-08T22:03:46Z","pushed_at":"2016-09-12T14:35:01Z","git_url":"git://github.com/kubernetes/kube-state-metrics.git","ssh_url":"git@github.com:kubernetes/kube-state-metrics.git","clone_url":"https://github.com/kubernetes/kube-state-metrics.git","svn_url":"https://github.com/kubernetes/kube-state-metrics","homepage":"","size":1885,"stargazers_count":21,"watchers_count":21,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":3,"forks":7,"open_issues":3,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/13"},"html":{"href":"https://github.com/kubernetes/kube-state-metrics/pull/13"},"issue":{"href":"https://api.github.com/repos/kubernetes/kube-state-metrics/issues/13"},"comments":{"href":"https://api.github.com/repos/kubernetes/kube-state-metrics/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kube-state-metrics/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kube-state-metrics/statuses/cb047f90d0e9b0e244584515622974bccf9ca5c7"}}}}
{"actor":{"display_login":"fabxc"}}