{"action":"created","comment":{"url":"https://api.github.com/repos/deislabs/smi-metrics/pulls/comments/303676421","pull_request_review_id":262121765,"id":303676421,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMwMzY3NjQyMQ==","diff_hunk":"@@ -0,0 +1,129 @@\n+package linkerd\n+\n+import (\n+\t\"context\"\n+\n+\t\"github.com/deislabs/smi-metrics/pkg/mesh\"\n+\n+\tpromv1 \"github.com/prometheus/client_golang/api/prometheus/v1\"\n+\n+\tmetav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"\n+\n+\t\"github.com/deislabs/smi-metrics/pkg/prometheus\"\n+\t\"github.com/deislabs/smi-sdk-go/pkg/apis/metrics\"\n+\t\"github.com/prometheus/client_golang/api\"\n+\tlog \"github.com/sirupsen/logrus\"\n+\tv1 \"k8s.io/api/core/v1\"\n+)\n+\n+type Config struct {\n+\tPrometheusURL   string            `yaml:\"prometheusUrl\"`\n+\tResourceQueries map[string]string `yaml:\"resourceQueries\"`\n+\tEdgeQueries     map[string]string `yaml:\"edgeQueries\"`\n+}\n+\n+type Linkerd struct {\n+\tqueries          mesh.Queries\n+\tprometheusClient promv1.API\n+}\n+\n+func (l *Linkerd) GetSupportedResources(ctx context.Context) (*metav1.APIResourceList, error) {\n+\tlst := &metav1.APIResourceList{\n+\t\tTypeMeta: metav1.TypeMeta{\n+\t\t\tKind:       \"APIResourceList\",\n+\t\t\tAPIVersion: \"v1\",\n+\t\t},\n+\t\tGroupVersion: metrics.APIVersion,\n+\t\tAPIResources: []metav1.APIResource{},\n+\t}\n+\n+\tfor _, v := range metrics.AvailableKinds {\n+\t\tlst.APIResources = append(lst.APIResources, *v)\n+\t}\n+\n+\treturn lst, nil\n+}\n+\n+func (l *Linkerd) GetEdgeMetrics(ctx context.Context,\n+\tname, namespace, kind string,\n+\tinterval *metrics.Interval,\n+\tdetails *mesh.ResourceDetails) (*metrics.TrafficMetricsList, error) {\n+\n+\tlookup := &edgeLookup{\n+\t\tItem: metrics.NewTrafficMetricsList(&v1.ObjectReference{\n+\t\t\tKind: kind,\n+\t\t\tName: name,\n+\t\t\t// If a namespace isn't defined, it'll be the empty string which fits\n+\t\t\t// with the struct's idea of \"empty\"\n+\t\t\tNamespace: namespace,\n+\t\t}, true),\n+\t\tdetails:  *details,\n+\t\tinterval: interval,\n+\t\tqueries:  l.queries.EdgeQueries,\n+\t}\n+\n+\tif err := prometheus.NewClient(ctx, l.prometheusClient, interval).Update(\n+\t\tlookup); err != nil {\n+\t\treturn nil, err\n+\t}\n+\treturn lookup.Item, nil\n+}\n+\n+func (l *Linkerd) GetResourceMetrics(ctx context.Context,\n+\tname, namespace, kind string,\n+\tinterval *metrics.Interval) (*metrics.TrafficMetricsList, error) {\n+\n+\tvar obj *v1.ObjectReference\n+\n+\tif name != \"\" {","path":"pkg/linkerd/linkerd.go","position":78,"original_position":78,"commit_id":"b677c91d17b3405bedffe51f5c8d340b006feec8","original_commit_id":"b677c91d17b3405bedffe51f5c8d340b006feec8","user":{"login":"grampelberg","id":47992,"node_id":"MDQ6VXNlcjQ3OTky","avatar_url":"https://avatars0.githubusercontent.com/u/47992?v=4","gravatar_id":"","url":"https://api.github.com/users/grampelberg","html_url":"https://github.com/grampelberg","followers_url":"https://api.github.com/users/grampelberg/followers","following_url":"https://api.github.com/users/grampelberg/following{/other_user}","gists_url":"https://api.github.com/users/grampelberg/gists{/gist_id}","starred_url":"https://api.github.com/users/grampelberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grampelberg/subscriptions","organizations_url":"https://api.github.com/users/grampelberg/orgs","repos_url":"https://api.github.com/users/grampelberg/repos","events_url":"https://api.github.com/users/grampelberg/events{/privacy}","received_events_url":"https://api.github.com/users/grampelberg/received_events","type":"User","site_admin":false},"body":"Can’t this be:\r\n\r\n```\r\nobj = &v1.ObjectReference{Kind: kind, Namespace: namespace}\r\nif name != “” {\r\n  obj.Name = name\r\n}\r\n```","created_at":"2019-07-15T23:26:49Z","updated_at":"2019-07-15T23:37:30Z","html_url":"https://github.com/deislabs/smi-metrics/pull/23#discussion_r303676421","pull_request_url":"https://api.github.com/repos/deislabs/smi-metrics/pulls/23","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/deislabs/smi-metrics/pulls/comments/303676421"},"html":{"href":"https://github.com/deislabs/smi-metrics/pull/23#discussion_r303676421"},"pull_request":{"href":"https://api.github.com/repos/deislabs/smi-metrics/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/deislabs/smi-metrics/pulls/23","id":297427542,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjk3NDI3NTQy","html_url":"https://github.com/deislabs/smi-metrics/pull/23","diff_url":"https://github.com/deislabs/smi-metrics/pull/23.diff","patch_url":"https://github.com/deislabs/smi-metrics/pull/23.patch","issue_url":"https://api.github.com/repos/deislabs/smi-metrics/issues/23","number":23,"state":"open","locked":false,"title":"Mesh Interface and Refactoring","user":{"login":"Pothulapati","id":7892868,"node_id":"MDQ6VXNlcjc4OTI4Njg=","avatar_url":"https://avatars1.githubusercontent.com/u/7892868?v=4","gravatar_id":"","url":"https://api.github.com/users/Pothulapati","html_url":"https://github.com/Pothulapati","followers_url":"https://api.github.com/users/Pothulapati/followers","following_url":"https://api.github.com/users/Pothulapati/following{/other_user}","gists_url":"https://api.github.com/users/Pothulapati/gists{/gist_id}","starred_url":"https://api.github.com/users/Pothulapati/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pothulapati/subscriptions","organizations_url":"https://api.github.com/users/Pothulapati/orgs","repos_url":"https://api.github.com/users/Pothulapati/repos","events_url":"https://api.github.com/users/Pothulapati/events{/privacy}","received_events_url":"https://api.github.com/users/Pothulapati/received_events","type":"User","site_admin":false},"body":"This PR adds `mesh` interface, through which more mesh implementations will be supported. This also moves the linkerd mesh implementation to a new package.\r\n\r\nTests will be added as a follow up using a mock `mesh` implementation.\r\n\r\n@grampelberg ","created_at":"2019-07-14T21:01:32Z","updated_at":"2019-07-15T23:37:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d33d0c032623aa6c85dcd812a0b565084e1e638f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/deislabs/smi-metrics/pulls/23/commits","review_comments_url":"https://api.github.com/repos/deislabs/smi-metrics/pulls/23/comments","review_comment_url":"https://api.github.com/repos/deislabs/smi-metrics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/deislabs/smi-metrics/issues/23/comments","statuses_url":"https://api.github.com/repos/deislabs/smi-metrics/statuses/b677c91d17b3405bedffe51f5c8d340b006feec8","head":{"label":"Pothulapati:plugins","ref":"plugins","sha":"b677c91d17b3405bedffe51f5c8d340b006feec8","user":{"login":"Pothulapati","id":7892868,"node_id":"MDQ6VXNlcjc4OTI4Njg=","avatar_url":"https://avatars1.githubusercontent.com/u/7892868?v=4","gravatar_id":"","url":"https://api.github.com/users/Pothulapati","html_url":"https://github.com/Pothulapati","followers_url":"https://api.github.com/users/Pothulapati/followers","following_url":"https://api.github.com/users/Pothulapati/following{/other_user}","gists_url":"https://api.github.com/users/Pothulapati/gists{/gist_id}","starred_url":"https://api.github.com/users/Pothulapati/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pothulapati/subscriptions","organizations_url":"https://api.github.com/users/Pothulapati/orgs","repos_url":"https://api.github.com/users/Pothulapati/repos","events_url":"https://api.github.com/users/Pothulapati/events{/privacy}","received_events_url":"https://api.github.com/users/Pothulapati/received_events","type":"User","site_admin":false},"repo":{"id":189233224,"node_id":"MDEwOlJlcG9zaXRvcnkxODkyMzMyMjQ=","name":"smi-metrics","full_name":"Pothulapati/smi-metrics","private":false,"owner":{"login":"Pothulapati","id":7892868,"node_id":"MDQ6VXNlcjc4OTI4Njg=","avatar_url":"https://avatars1.githubusercontent.com/u/7892868?v=4","gravatar_id":"","url":"https://api.github.com/users/Pothulapati","html_url":"https://github.com/Pothulapati","followers_url":"https://api.github.com/users/Pothulapati/followers","following_url":"https://api.github.com/users/Pothulapati/following{/other_user}","gists_url":"https://api.github.com/users/Pothulapati/gists{/gist_id}","starred_url":"https://api.github.com/users/Pothulapati/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pothulapati/subscriptions","organizations_url":"https://api.github.com/users/Pothulapati/orgs","repos_url":"https://api.github.com/users/Pothulapati/repos","events_url":"https://api.github.com/users/Pothulapati/events{/privacy}","received_events_url":"https://api.github.com/users/Pothulapati/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Pothulapati/smi-metrics","description":"Expose SMI Metrics","fork":true,"url":"https://api.github.com/repos/Pothulapati/smi-metrics","forks_url":"https://api.github.com/repos/Pothulapati/smi-metrics/forks","keys_url":"https://api.github.com/repos/Pothulapati/smi-metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Pothulapati/smi-metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Pothulapati/smi-metrics/teams","hooks_url":"https://api.github.com/repos/Pothulapati/smi-metrics/hooks","issue_events_url":"https://api.github.com/repos/Pothulapati/smi-metrics/issues/events{/number}","events_url":"https://api.github.com/repos/Pothulapati/smi-metrics/events","assignees_url":"https://api.github.com/repos/Pothulapati/smi-metrics/assignees{/user}","branches_url":"https://api.github.com/repos/Pothulapati/smi-metrics/branches{/branch}","tags_url":"https://api.github.com/repos/Pothulapati/smi-metrics/tags","blobs_url":"https://api.github.com/repos/Pothulapati/smi-metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Pothulapati/smi-metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Pothulapati/smi-metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/Pothulapati/smi-metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Pothulapati/smi-metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/Pothulapati/smi-metrics/languages","stargazers_url":"https://api.github.com/repos/Pothulapati/smi-metrics/stargazers","contributors_url":"https://api.github.com/repos/Pothulapati/smi-metrics/contributors","subscribers_url":"https://api.github.com/repos/Pothulapati/smi-metrics/subscribers","subscription_url":"https://api.github.com/repos/Pothulapati/smi-metrics/subscription","commits_url":"https://api.github.com/repos/Pothulapati/smi-metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/Pothulapati/smi-metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/Pothulapati/smi-metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/Pothulapati/smi-metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/Pothulapati/smi-metrics/contents/{+path}","compare_url":"https://api.github.com/repos/Pothulapati/smi-metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Pothulapati/smi-metrics/merges","archive_url":"https://api.github.com/repos/Pothulapati/smi-metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Pothulapati/smi-metrics/downloads","issues_url":"https://api.github.com/repos/Pothulapati/smi-metrics/issues{/number}","pulls_url":"https://api.github.com/repos/Pothulapati/smi-metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/Pothulapati/smi-metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/Pothulapati/smi-metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Pothulapati/smi-metrics/labels{/name}","releases_url":"https://api.github.com/repos/Pothulapati/smi-metrics/releases{/id}","deployments_url":"https://api.github.com/repos/Pothulapati/smi-metrics/deployments","created_at":"2019-05-29T13:40:42Z","updated_at":"2019-06-26T17:32:47Z","pushed_at":"2019-07-14T20:59:25Z","git_url":"git://github.com/Pothulapati/smi-metrics.git","ssh_url":"git@github.com:Pothulapati/smi-metrics.git","clone_url":"https://github.com/Pothulapati/smi-metrics.git","svn_url":"https://github.com/Pothulapati/smi-metrics","homepage":"","size":96,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"deislabs:master","ref":"master","sha":"a1e996c7599415030099ff63ae5507ca1dcc5e66","user":{"login":"deislabs","id":44041561,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MDQxNTYx","avatar_url":"https://avatars1.githubusercontent.com/u/44041561?v=4","gravatar_id":"","url":"https://api.github.com/users/deislabs","html_url":"https://github.com/deislabs","followers_url":"https://api.github.com/users/deislabs/followers","following_url":"https://api.github.com/users/deislabs/following{/other_user}","gists_url":"https://api.github.com/users/deislabs/gists{/gist_id}","starred_url":"https://api.github.com/users/deislabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deislabs/subscriptions","organizations_url":"https://api.github.com/users/deislabs/orgs","repos_url":"https://api.github.com/users/deislabs/repos","events_url":"https://api.github.com/users/deislabs/events{/privacy}","received_events_url":"https://api.github.com/users/deislabs/received_events","type":"Organization","site_admin":false},"repo":{"id":182124110,"node_id":"MDEwOlJlcG9zaXRvcnkxODIxMjQxMTA=","name":"smi-metrics","full_name":"deislabs/smi-metrics","private":false,"owner":{"login":"deislabs","id":44041561,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MDQxNTYx","avatar_url":"https://avatars1.githubusercontent.com/u/44041561?v=4","gravatar_id":"","url":"https://api.github.com/users/deislabs","html_url":"https://github.com/deislabs","followers_url":"https://api.github.com/users/deislabs/followers","following_url":"https://api.github.com/users/deislabs/following{/other_user}","gists_url":"https://api.github.com/users/deislabs/gists{/gist_id}","starred_url":"https://api.github.com/users/deislabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deislabs/subscriptions","organizations_url":"https://api.github.com/users/deislabs/orgs","repos_url":"https://api.github.com/users/deislabs/repos","events_url":"https://api.github.com/users/deislabs/events{/privacy}","received_events_url":"https://api.github.com/users/deislabs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/deislabs/smi-metrics","description":"Expose SMI Metrics","fork":false,"url":"https://api.github.com/repos/deislabs/smi-metrics","forks_url":"https://api.github.com/repos/deislabs/smi-metrics/forks","keys_url":"https://api.github.com/repos/deislabs/smi-metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/deislabs/smi-metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/deislabs/smi-metrics/teams","hooks_url":"https://api.github.com/repos/deislabs/smi-metrics/hooks","issue_events_url":"https://api.github.com/repos/deislabs/smi-metrics/issues/events{/number}","events_url":"https://api.github.com/repos/deislabs/smi-metrics/events","assignees_url":"https://api.github.com/repos/deislabs/smi-metrics/assignees{/user}","branches_url":"https://api.github.com/repos/deislabs/smi-metrics/branches{/branch}","tags_url":"https://api.github.com/repos/deislabs/smi-metrics/tags","blobs_url":"https://api.github.com/repos/deislabs/smi-metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/deislabs/smi-metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/deislabs/smi-metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/deislabs/smi-metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/deislabs/smi-metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/deislabs/smi-metrics/languages","stargazers_url":"https://api.github.com/repos/deislabs/smi-metrics/stargazers","contributors_url":"https://api.github.com/repos/deislabs/smi-metrics/contributors","subscribers_url":"https://api.github.com/repos/deislabs/smi-metrics/subscribers","subscription_url":"https://api.github.com/repos/deislabs/smi-metrics/subscription","commits_url":"https://api.github.com/repos/deislabs/smi-metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/deislabs/smi-metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/deislabs/smi-metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/deislabs/smi-metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/deislabs/smi-metrics/contents/{+path}","compare_url":"https://api.github.com/repos/deislabs/smi-metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/deislabs/smi-metrics/merges","archive_url":"https://api.github.com/repos/deislabs/smi-metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/deislabs/smi-metrics/downloads","issues_url":"https://api.github.com/repos/deislabs/smi-metrics/issues{/number}","pulls_url":"https://api.github.com/repos/deislabs/smi-metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/deislabs/smi-metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/deislabs/smi-metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/deislabs/smi-metrics/labels{/name}","releases_url":"https://api.github.com/repos/deislabs/smi-metrics/releases{/id}","deployments_url":"https://api.github.com/repos/deislabs/smi-metrics/deployments","created_at":"2019-04-18T16:45:36Z","updated_at":"2019-07-03T14:49:57Z","pushed_at":"2019-07-14T21:01:33Z","git_url":"git://github.com/deislabs/smi-metrics.git","ssh_url":"git@github.com:deislabs/smi-metrics.git","clone_url":"https://github.com/deislabs/smi-metrics.git","svn_url":"https://github.com/deislabs/smi-metrics","homepage":"","size":50,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":7,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":4,"open_issues":7,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/deislabs/smi-metrics/pulls/23"},"html":{"href":"https://github.com/deislabs/smi-metrics/pull/23"},"issue":{"href":"https://api.github.com/repos/deislabs/smi-metrics/issues/23"},"comments":{"href":"https://api.github.com/repos/deislabs/smi-metrics/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/deislabs/smi-metrics/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/deislabs/smi-metrics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/deislabs/smi-metrics/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/deislabs/smi-metrics/statuses/b677c91d17b3405bedffe51f5c8d340b006feec8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"grampelberg"}}