{"action":"created","comment":{"url":"https://api.github.com/repos/zalando/skipper/pulls/comments/227777100","pull_request_review_id":167882037,"id":227777100,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzc3NzEwMA==","diff_hunk":"@@ -0,0 +1,126 @@\n+package apiusagemonitoring\n+\n+import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"github.com/zalando/skipper/filters\"\n+\t\"net/http\"\n+\t\"time\"\n+)\n+\n+const (\n+\tmetricCountAll  = \"http_count\"\n+\tmetricCount500s = \"http5xx_count\"\n+\tmetricCount400s = \"http4xx_count\"\n+\tmetricCount300s = \"http3xx_count\"\n+\tmetricCount200s = \"http2xx_count\"\n+\tmetricCount100s = \"http1xx_count\"\n+\tmetricLatency   = \"latency\"\n+)\n+\n+const (\n+\tstateBagKeyPrefix = \"filter.\" + Name + \".\"\n+\tstateBagKeyState  = stateBagKeyPrefix + \"state\"\n+)\n+\n+// apiUsageMonitoringFilter implements filters.Filter interface and is the structure\n+// created for every route invocation of the `apiUsageMonitoring` filter.\n+type apiUsageMonitoringFilter struct {\n+\tPaths []*pathInfo\n+}\n+\n+// apiUsageMonitoringFilterContext contains information about the metrics tracking\n+// for one HTTP exchange (one routing). It serves to pass information from\n+// the `Request` call to the `Response` call (stored in the context's `StateBag`).\n+type apiUsageMonitoringFilterContext struct {\n+\t// Begin is the earliest point in time where the request is observed\n+\tBegin time.Time\n+}\n+\n+func (f *apiUsageMonitoringFilter) Request(c filters.FilterContext) {\n+\t// Gathering information from the initial request for further metrics calculation\n+\tc.StateBag()[stateBagKeyState] = &apiUsageMonitoringFilterContext{\n+\t\tBegin: time.Now(),\n+\t}\n+}\n+\n+func (f *apiUsageMonitoringFilter) Response(c filters.FilterContext) {\n+\tmfc, ok := c.StateBag()[stateBagKeyState].(*apiUsageMonitoringFilterContext)\n+\tif !ok {","path":"filters/apiusagemonitoring/filter.go","position":49,"original_position":49,"commit_id":"b805c6273882708aee96951165147afa39c9786a","original_commit_id":"c44ec40bc5334dcf0705bd434a7ff22082e8d709","user":{"login":"tkrop","id":18184975,"node_id":"MDQ6VXNlcjE4MTg0OTc1","avatar_url":"https://avatars1.githubusercontent.com/u/18184975?v=4","gravatar_id":"","url":"https://api.github.com/users/tkrop","html_url":"https://github.com/tkrop","followers_url":"https://api.github.com/users/tkrop/followers","following_url":"https://api.github.com/users/tkrop/following{/other_user}","gists_url":"https://api.github.com/users/tkrop/gists{/gist_id}","starred_url":"https://api.github.com/users/tkrop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkrop/subscriptions","organizations_url":"https://api.github.com/users/tkrop/orgs","repos_url":"https://api.github.com/users/tkrop/repos","events_url":"https://api.github.com/users/tkrop/events{/privacy}","received_events_url":"https://api.github.com/users/tkrop/received_events","type":"User","site_admin":false},"body":"Left over that opens up an interesting question. Can this happen at all? Should we deny to monitor anything?\r\n\r\nI would suggest to measure the counts and status code but leave out the latency.","created_at":"2018-10-24T13:01:48Z","updated_at":"2018-10-24T13:34:48Z","html_url":"https://github.com/zalando/skipper/pull/818#discussion_r227777100","pull_request_url":"https://api.github.com/repos/zalando/skipper/pulls/818","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/zalando/skipper/pulls/comments/227777100"},"html":{"href":"https://github.com/zalando/skipper/pull/818#discussion_r227777100"},"pull_request":{"href":"https://api.github.com/repos/zalando/skipper/pulls/818"}}},"pull_request":{"url":"https://api.github.com/repos/zalando/skipper/pulls/818","id":221839776,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxODM5Nzc2","html_url":"https://github.com/zalando/skipper/pull/818","diff_url":"https://github.com/zalando/skipper/pull/818.diff","patch_url":"https://github.com/zalando/skipper/pull/818.patch","issue_url":"https://api.github.com/repos/zalando/skipper/issues/818","number":818,"state":"open","locked":false,"title":"API Monitoring Filter: MVP","user":{"login":"ddufourboivin-zalando","id":39987010,"node_id":"MDQ6VXNlcjM5OTg3MDEw","avatar_url":"https://avatars3.githubusercontent.com/u/39987010?v=4","gravatar_id":"","url":"https://api.github.com/users/ddufourboivin-zalando","html_url":"https://github.com/ddufourboivin-zalando","followers_url":"https://api.github.com/users/ddufourboivin-zalando/followers","following_url":"https://api.github.com/users/ddufourboivin-zalando/following{/other_user}","gists_url":"https://api.github.com/users/ddufourboivin-zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/ddufourboivin-zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddufourboivin-zalando/subscriptions","organizations_url":"https://api.github.com/users/ddufourboivin-zalando/orgs","repos_url":"https://api.github.com/users/ddufourboivin-zalando/repos","events_url":"https://api.github.com/users/ddufourboivin-zalando/events{/privacy}","received_events_url":"https://api.github.com/users/ddufourboivin-zalando/received_events","type":"User","site_admin":false},"body":"This represent the first usable version (MVP) of the _monitoring_ aspect of the _API Gateway_ project Team _API Management_ (part of Team _Architecture_).\r\n\r\nIt is our first contribution to _Skipper_, so of course any comments on how to contribute is welcome as are any general _GO Best Practices_ pointers.\r\n","created_at":"2018-10-10T15:41:16Z","updated_at":"2018-10-24T13:34:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15c50253c990090215933c48f6dc2563c84c9d50","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/zalando/skipper/pulls/818/commits","review_comments_url":"https://api.github.com/repos/zalando/skipper/pulls/818/comments","review_comment_url":"https://api.github.com/repos/zalando/skipper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zalando/skipper/issues/818/comments","statuses_url":"https://api.github.com/repos/zalando/skipper/statuses/b805c6273882708aee96951165147afa39c9786a","head":{"label":"ddufourboivin-zalando:api-portal-monitoring","ref":"api-portal-monitoring","sha":"b805c6273882708aee96951165147afa39c9786a","user":{"login":"ddufourboivin-zalando","id":39987010,"node_id":"MDQ6VXNlcjM5OTg3MDEw","avatar_url":"https://avatars3.githubusercontent.com/u/39987010?v=4","gravatar_id":"","url":"https://api.github.com/users/ddufourboivin-zalando","html_url":"https://github.com/ddufourboivin-zalando","followers_url":"https://api.github.com/users/ddufourboivin-zalando/followers","following_url":"https://api.github.com/users/ddufourboivin-zalando/following{/other_user}","gists_url":"https://api.github.com/users/ddufourboivin-zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/ddufourboivin-zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddufourboivin-zalando/subscriptions","organizations_url":"https://api.github.com/users/ddufourboivin-zalando/orgs","repos_url":"https://api.github.com/users/ddufourboivin-zalando/repos","events_url":"https://api.github.com/users/ddufourboivin-zalando/events{/privacy}","received_events_url":"https://api.github.com/users/ddufourboivin-zalando/received_events","type":"User","site_admin":false},"repo":{"id":147189613,"node_id":"MDEwOlJlcG9zaXRvcnkxNDcxODk2MTM=","name":"skipper","full_name":"ddufourboivin-zalando/skipper","private":false,"owner":{"login":"ddufourboivin-zalando","id":39987010,"node_id":"MDQ6VXNlcjM5OTg3MDEw","avatar_url":"https://avatars3.githubusercontent.com/u/39987010?v=4","gravatar_id":"","url":"https://api.github.com/users/ddufourboivin-zalando","html_url":"https://github.com/ddufourboivin-zalando","followers_url":"https://api.github.com/users/ddufourboivin-zalando/followers","following_url":"https://api.github.com/users/ddufourboivin-zalando/following{/other_user}","gists_url":"https://api.github.com/users/ddufourboivin-zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/ddufourboivin-zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddufourboivin-zalando/subscriptions","organizations_url":"https://api.github.com/users/ddufourboivin-zalando/orgs","repos_url":"https://api.github.com/users/ddufourboivin-zalando/repos","events_url":"https://api.github.com/users/ddufourboivin-zalando/events{/privacy}","received_events_url":"https://api.github.com/users/ddufourboivin-zalando/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ddufourboivin-zalando/skipper","description":"An HTTP router and reverse proxy for service composition, including use cases like Kubernetes Ingress","fork":true,"url":"https://api.github.com/repos/ddufourboivin-zalando/skipper","forks_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/forks","keys_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/teams","hooks_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/hooks","issue_events_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/issues/events{/number}","events_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/events","assignees_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/assignees{/user}","branches_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/branches{/branch}","tags_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/tags","blobs_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/git/refs{/sha}","trees_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/statuses/{sha}","languages_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/languages","stargazers_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/stargazers","contributors_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/contributors","subscribers_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/subscribers","subscription_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/subscription","commits_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/commits{/sha}","git_commits_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/git/commits{/sha}","comments_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/comments{/number}","issue_comment_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/issues/comments{/number}","contents_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/contents/{+path}","compare_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/merges","archive_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/downloads","issues_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/issues{/number}","pulls_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/pulls{/number}","milestones_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/milestones{/number}","notifications_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/labels{/name}","releases_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/releases{/id}","deployments_url":"https://api.github.com/repos/ddufourboivin-zalando/skipper/deployments","created_at":"2018-09-03T10:34:55Z","updated_at":"2018-10-11T08:11:00Z","pushed_at":"2018-10-24T13:14:43Z","git_url":"git://github.com/ddufourboivin-zalando/skipper.git","ssh_url":"git@github.com:ddufourboivin-zalando/skipper.git","clone_url":"https://github.com/ddufourboivin-zalando/skipper.git","svn_url":"https://github.com/ddufourboivin-zalando/skipper","homepage":"https://opensource.zalando.com/skipper/","size":8536,"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,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"zalando:master","ref":"master","sha":"7d1e7ba519fc513bae8a7ecb8a5faec398c24ef1","user":{"login":"zalando","id":1564818,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NjQ4MTg=","avatar_url":"https://avatars0.githubusercontent.com/u/1564818?v=4","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"repo":{"id":38812664,"node_id":"MDEwOlJlcG9zaXRvcnkzODgxMjY2NA==","name":"skipper","full_name":"zalando/skipper","private":false,"owner":{"login":"zalando","id":1564818,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NjQ4MTg=","avatar_url":"https://avatars0.githubusercontent.com/u/1564818?v=4","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/zalando/skipper","description":"An HTTP router and reverse proxy for service composition, including use cases like Kubernetes Ingress","fork":false,"url":"https://api.github.com/repos/zalando/skipper","forks_url":"https://api.github.com/repos/zalando/skipper/forks","keys_url":"https://api.github.com/repos/zalando/skipper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zalando/skipper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zalando/skipper/teams","hooks_url":"https://api.github.com/repos/zalando/skipper/hooks","issue_events_url":"https://api.github.com/repos/zalando/skipper/issues/events{/number}","events_url":"https://api.github.com/repos/zalando/skipper/events","assignees_url":"https://api.github.com/repos/zalando/skipper/assignees{/user}","branches_url":"https://api.github.com/repos/zalando/skipper/branches{/branch}","tags_url":"https://api.github.com/repos/zalando/skipper/tags","blobs_url":"https://api.github.com/repos/zalando/skipper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zalando/skipper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zalando/skipper/git/refs{/sha}","trees_url":"https://api.github.com/repos/zalando/skipper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zalando/skipper/statuses/{sha}","languages_url":"https://api.github.com/repos/zalando/skipper/languages","stargazers_url":"https://api.github.com/repos/zalando/skipper/stargazers","contributors_url":"https://api.github.com/repos/zalando/skipper/contributors","subscribers_url":"https://api.github.com/repos/zalando/skipper/subscribers","subscription_url":"https://api.github.com/repos/zalando/skipper/subscription","commits_url":"https://api.github.com/repos/zalando/skipper/commits{/sha}","git_commits_url":"https://api.github.com/repos/zalando/skipper/git/commits{/sha}","comments_url":"https://api.github.com/repos/zalando/skipper/comments{/number}","issue_comment_url":"https://api.github.com/repos/zalando/skipper/issues/comments{/number}","contents_url":"https://api.github.com/repos/zalando/skipper/contents/{+path}","compare_url":"https://api.github.com/repos/zalando/skipper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zalando/skipper/merges","archive_url":"https://api.github.com/repos/zalando/skipper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zalando/skipper/downloads","issues_url":"https://api.github.com/repos/zalando/skipper/issues{/number}","pulls_url":"https://api.github.com/repos/zalando/skipper/pulls{/number}","milestones_url":"https://api.github.com/repos/zalando/skipper/milestones{/number}","notifications_url":"https://api.github.com/repos/zalando/skipper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zalando/skipper/labels{/name}","releases_url":"https://api.github.com/repos/zalando/skipper/releases{/id}","deployments_url":"https://api.github.com/repos/zalando/skipper/deployments","created_at":"2015-07-09T09:54:40Z","updated_at":"2018-10-24T09:19:23Z","pushed_at":"2018-10-24T13:14:45Z","git_url":"git://github.com/zalando/skipper.git","ssh_url":"git@github.com:zalando/skipper.git","clone_url":"https://github.com/zalando/skipper.git","svn_url":"https://github.com/zalando/skipper","homepage":"https://opensource.zalando.com/skipper/","size":8444,"stargazers_count":1248,"watchers_count":1248,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":119,"mirror_url":null,"archived":false,"open_issues_count":107,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":119,"open_issues":107,"watchers":1248,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zalando/skipper/pulls/818"},"html":{"href":"https://github.com/zalando/skipper/pull/818"},"issue":{"href":"https://api.github.com/repos/zalando/skipper/issues/818"},"comments":{"href":"https://api.github.com/repos/zalando/skipper/issues/818/comments"},"review_comments":{"href":"https://api.github.com/repos/zalando/skipper/pulls/818/comments"},"review_comment":{"href":"https://api.github.com/repos/zalando/skipper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zalando/skipper/pulls/818/commits"},"statuses":{"href":"https://api.github.com/repos/zalando/skipper/statuses/b805c6273882708aee96951165147afa39c9786a"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"tkrop"}}