{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/etcd/pulls/comments/40778450","id":40778450,"diff_hunk":"@@ -0,0 +1,96 @@\n+// Copyright 2015 CoreOS, Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package etcdhttp\n+\n+import (\n+\t\"strconv\"\n+\t\"time\"\n+\n+\t\"github.com/coreos/etcd/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus\"\n+\tetcdErr \"github.com/coreos/etcd/error\"\n+\t\"github.com/coreos/etcd/etcdserver\"\n+\t\"github.com/coreos/etcd/etcdserver/etcdhttp/httptypes\"\n+\t\"github.com/coreos/etcd/etcdserver/etcdserverpb\"\n+)\n+\n+var (\n+\tincomingEvents = prometheus.NewCounterVec(\n+\t\tprometheus.CounterOpts{\n+\t\t\tNamespace: \"etcd\",\n+\t\t\tSubsystem: \"http\",\n+\t\t\tName:      \"events_received_total\",\n+\t\t\tHelp:      \"Counter of events accepted into the system (successfully parsed and authd).\",\n+\t\t}, []string{\"method\"})\n+\n+\tfailedEvents = prometheus.NewCounterVec(\n+\t\tprometheus.CounterOpts{\n+\t\t\tNamespace: \"etcd\",\n+\t\t\tSubsystem: \"http\",\n+\t\t\tName:      \"events_failed_total\",\n+\t\t\tHelp: \"Counter of handle failures of events (non-watches), by method (GET/PUT etc.) and code \" +\n+\t\t\t\t\"(400, 500 etc.).\",\n+\t\t}, []string{\"method\", \"code\"})\n+\n+\tsuccessfulEventsHandlingTime = prometheus.NewHistogramVec(","path":"etcdserver/etcdhttp/metrics.go","position":46,"original_position":46,"commit_id":"a60b18e1d28e91818b69b863ba65b0e9ff1252d7","original_commit_id":"a60b18e1d28e91818b69b863ba65b0e9ff1252d7","user":{"login":"mwitkow-io","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow-io","html_url":"https://github.com/mwitkow-io","followers_url":"https://api.github.com/users/mwitkow-io/followers","following_url":"https://api.github.com/users/mwitkow-io/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow-io/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow-io/subscriptions","organizations_url":"https://api.github.com/users/mwitkow-io/orgs","repos_url":"https://api.github.com/users/mwitkow-io/repos","events_url":"https://api.github.com/users/mwitkow-io/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow-io/received_events","type":"User","site_admin":false},"body":"why microsecond? it is in seconds, which is IMHO the right call as Prometheus uses floats and this is the `base` unit for time. + the bucket is in `prometheus.ExponentialBuckets(0.0005, 2, 13)`","created_at":"2015-09-30T10:16:36Z","updated_at":"2015-09-30T10:16:36Z","html_url":"https://github.com/coreos/etcd/pull/3093#discussion_r40778450","pull_request_url":"https://api.github.com/repos/coreos/etcd/pulls/3093","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments/40778450"},"html":{"href":"https://github.com/coreos/etcd/pull/3093#discussion_r40778450"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd/pulls/3093"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/etcd/pulls/3093","id":39086366,"html_url":"https://github.com/coreos/etcd/pull/3093","diff_url":"https://github.com/coreos/etcd/pull/3093.diff","patch_url":"https://github.com/coreos/etcd/pull/3093.patch","issue_url":"https://api.github.com/repos/coreos/etcd/issues/3093","number":3093,"state":"open","locked":false,"title":"add `events` metrics in etcdhttp.","user":{"login":"mwitkow-io","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow-io","html_url":"https://github.com/mwitkow-io","followers_url":"https://api.github.com/users/mwitkow-io/followers","following_url":"https://api.github.com/users/mwitkow-io/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow-io/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow-io/subscriptions","organizations_url":"https://api.github.com/users/mwitkow-io/orgs","repos_url":"https://api.github.com/users/mwitkow-io/repos","events_url":"https://api.github.com/users/mwitkow-io/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow-io/received_events","type":"User","site_admin":false},"body":"This is a follow up of:\r\nhttps://github.com/coreos/etcd/pull/3001\r\n\r\n@xiang90, @philips  and @yichengq asked to move `etcdhttp/metrics.go` into a separate PR.\r\nThe commit has been cleaned up and made in-sync with the conventions recommended in #3001.\r\n\r\nWe currently are using these in our custom build of etcd and use the failure/total and latency metrics for alerting purposes. We've found that having etcd latency metrics is incredibly useful when troubleshooting latency issues of third party services that rely on etcd (including stuff we've built ourselves).\r\n","created_at":"2015-07-02T14:10:31Z","updated_at":"2015-09-30T10:16:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dd61fec9ce78f3c11dd9bd9fb00fb2d3e1908cc7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/coreos/etcd/pulls/3093/commits","review_comments_url":"https://api.github.com/repos/coreos/etcd/pulls/3093/comments","review_comment_url":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/etcd/issues/3093/comments","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/a60b18e1d28e91818b69b863ba65b0e9ff1252d7","head":{"label":"mwitkow-io:feature/httpd_metrics","ref":"feature/httpd_metrics","sha":"a60b18e1d28e91818b69b863ba65b0e9ff1252d7","user":{"login":"mwitkow-io","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow-io","html_url":"https://github.com/mwitkow-io","followers_url":"https://api.github.com/users/mwitkow-io/followers","following_url":"https://api.github.com/users/mwitkow-io/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow-io/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow-io/subscriptions","organizations_url":"https://api.github.com/users/mwitkow-io/orgs","repos_url":"https://api.github.com/users/mwitkow-io/repos","events_url":"https://api.github.com/users/mwitkow-io/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow-io/received_events","type":"User","site_admin":false},"repo":{"id":37594335,"name":"etcd","full_name":"mwitkow-io/etcd","owner":{"login":"mwitkow-io","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow-io","html_url":"https://github.com/mwitkow-io","followers_url":"https://api.github.com/users/mwitkow-io/followers","following_url":"https://api.github.com/users/mwitkow-io/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow-io/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow-io/subscriptions","organizations_url":"https://api.github.com/users/mwitkow-io/orgs","repos_url":"https://api.github.com/users/mwitkow-io/repos","events_url":"https://api.github.com/users/mwitkow-io/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow-io/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mwitkow-io/etcd","description":"A highly-available key-value store for shared configuration and service discovery","fork":true,"url":"https://api.github.com/repos/mwitkow-io/etcd","forks_url":"https://api.github.com/repos/mwitkow-io/etcd/forks","keys_url":"https://api.github.com/repos/mwitkow-io/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mwitkow-io/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mwitkow-io/etcd/teams","hooks_url":"https://api.github.com/repos/mwitkow-io/etcd/hooks","issue_events_url":"https://api.github.com/repos/mwitkow-io/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/mwitkow-io/etcd/events","assignees_url":"https://api.github.com/repos/mwitkow-io/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/mwitkow-io/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/mwitkow-io/etcd/tags","blobs_url":"https://api.github.com/repos/mwitkow-io/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mwitkow-io/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mwitkow-io/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/mwitkow-io/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mwitkow-io/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/mwitkow-io/etcd/languages","stargazers_url":"https://api.github.com/repos/mwitkow-io/etcd/stargazers","contributors_url":"https://api.github.com/repos/mwitkow-io/etcd/contributors","subscribers_url":"https://api.github.com/repos/mwitkow-io/etcd/subscribers","subscription_url":"https://api.github.com/repos/mwitkow-io/etcd/subscription","commits_url":"https://api.github.com/repos/mwitkow-io/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/mwitkow-io/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/mwitkow-io/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/mwitkow-io/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/mwitkow-io/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/mwitkow-io/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mwitkow-io/etcd/merges","archive_url":"https://api.github.com/repos/mwitkow-io/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mwitkow-io/etcd/downloads","issues_url":"https://api.github.com/repos/mwitkow-io/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/mwitkow-io/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/mwitkow-io/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/mwitkow-io/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mwitkow-io/etcd/labels{/name}","releases_url":"https://api.github.com/repos/mwitkow-io/etcd/releases{/id}","created_at":"2015-06-17T12:47:09Z","updated_at":"2015-06-17T12:47:11Z","pushed_at":"2015-09-30T10:11:22Z","git_url":"git://github.com/mwitkow-io/etcd.git","ssh_url":"git@github.com:mwitkow-io/etcd.git","clone_url":"https://github.com/mwitkow-io/etcd.git","svn_url":"https://github.com/mwitkow-io/etcd","homepage":"","size":18714,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"coreos:master","ref":"master","sha":"783884a04edb9ac99c4274ce9979e07dc51bdf47","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":11225014,"name":"etcd","full_name":"coreos/etcd","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/etcd","description":"A distributed consistent key-value store for shared configuration and service discovery","fork":false,"url":"https://api.github.com/repos/coreos/etcd","forks_url":"https://api.github.com/repos/coreos/etcd/forks","keys_url":"https://api.github.com/repos/coreos/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd/teams","hooks_url":"https://api.github.com/repos/coreos/etcd/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd/events","assignees_url":"https://api.github.com/repos/coreos/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd/tags","blobs_url":"https://api.github.com/repos/coreos/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd/subscription","commits_url":"https://api.github.com/repos/coreos/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd/merges","archive_url":"https://api.github.com/repos/coreos/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd/downloads","issues_url":"https://api.github.com/repos/coreos/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd/releases{/id}","created_at":"2013-07-06T21:57:21Z","updated_at":"2015-09-30T03:24:03Z","pushed_at":"2015-09-30T10:11:25Z","git_url":"git://github.com/coreos/etcd.git","ssh_url":"git@github.com:coreos/etcd.git","clone_url":"https://github.com/coreos/etcd.git","svn_url":"https://github.com/coreos/etcd","homepage":"","size":37071,"stargazers_count":7624,"watchers_count":7624,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1128,"mirror_url":null,"open_issues_count":121,"forks":1128,"open_issues":121,"watchers":7624,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/3093"},"html":{"href":"https://github.com/coreos/etcd/pull/3093"},"issue":{"href":"https://api.github.com/repos/coreos/etcd/issues/3093"},"comments":{"href":"https://api.github.com/repos/coreos/etcd/issues/3093/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/etcd/pulls/3093/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/etcd/pulls/3093/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/etcd/statuses/a60b18e1d28e91818b69b863ba65b0e9ff1252d7"}}}}