{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/client_java/pulls/comments/64696971","id":64696971,"diff_hunk":"@@ -0,0 +1,81 @@\n+package io.prometheus.client.jetty;\n+\n+import io.prometheus.client.Collector;\n+import org.eclipse.jetty.server.handler.StatisticsHandler;\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.Collections;\n+import java.util.List;\n+\n+/**\n+ * Collect metrics from jettty's org.eclipse.jetty.server.handler.StatisticsHandler.\n+ */\n+public class JettyStatisticsCollector extends Collector {\n+  private final StatisticsHandler statisticsHandler;\n+  private static final List<String> EMPTY_LIST = new ArrayList<String>();\n+\n+  public JettyStatisticsCollector(StatisticsHandler statisticsHandler) {\n+    this.statisticsHandler = statisticsHandler;\n+  }\n+\n+  @Override\n+  public List<MetricFamilySamples> collect() {\n+    return Arrays.asList(\n+            buildGauge(\"jetty_requests\", \"number of requests\", statisticsHandler.getRequests()),\n+            buildGauge(\"jetty_requests_active\", \"number of requests currently active\", statisticsHandler.getRequestsActive()),\n+            buildGauge(\"jetty_requests_active_max\", \"maximum number of active requests\", statisticsHandler.getRequestsActiveMax()),\n+            buildGauge(\"jetty_request_time_max\", \"maximum time spend handling requests (in ms)\", statisticsHandler.getRequestTimeMax()),\n+            buildGauge(\"jetty_request_time_total\", \"total time spend in all request handling (in ms)\", statisticsHandler.getRequestTimeTotal()),\n+            buildGauge(\"jetty_request_time_mean\", \"mean time spent handling requests (in ms)\", statisticsHandler.getRequestTimeMean()),\n+            buildGauge(\"jetty_request_time_std_dev\", \"standard deviation for request handling (in ms)\", statisticsHandler.getRequestTimeStdDev()),\n+            buildGauge(\"jetty_dispatched\", \"number of dispatches\", statisticsHandler.getDispatched()),\n+            buildGauge(\"jetty_dispatched_active\", \"number of dispatches currently active\", statisticsHandler.getDispatchedActive()),\n+            buildGauge(\"jetty_dispatched_active_max\", \"maximum number of active dispatches being handled\", statisticsHandler.getDispatchedActiveMax()),\n+            buildGauge(\"jetty_dispatched_time_max\", \"maximum time spend in dispatch handling\", statisticsHandler.getDispatchedTimeMax()),\n+            buildGauge(\"jetty_dispatched_time_total\", \"total time spent in dispatch handling (in ms)\", statisticsHandler.getDispatchedTimeTotal()),\n+            buildGauge(\"jetty_dispatched_time_mean\", \"mean time spent in dispatch handling (in ms)\", statisticsHandler.getDispatchedTimeMean()),\n+            buildGauge(\"jetty_dispatched_time_std_dev\", \"standard deviation for dispatch handling (in ms)\", statisticsHandler.getDispatchedTimeStdDev()),\n+            buildGauge(\"jetty_async_requests\", \"total number of async requests\", statisticsHandler.getAsyncRequests()),\n+            buildGauge(\"jetty_async_requests_waiting\", \"currently waiting async requests\", statisticsHandler.getAsyncRequestsWaiting()),\n+            buildGauge(\"jetty_async_requests_waiting_max\", \"maximum number of waiting async requests\", statisticsHandler.getAsyncRequestsWaitingMax()),\n+            buildGauge(\"jetty_async_dispatches\", \"number of requested that have been asynchronously dispatched\", statisticsHandler.getAsyncDispatches()),\n+            buildGauge(\"jetty_expires\", \"number of async requests requests that have expired\", statisticsHandler.getExpires()),\n+            buildStatusGauge(),\n+            buildGauge(\"jetty_stats_on_ms\", \"time in milliseconds stats have been collected for\", statisticsHandler.getStatsOnMs()),\n+            buildGauge(\"jetty_responses_bytes_total\", \"total number of bytes across all responses\", statisticsHandler.getResponsesBytesTotal())\n+    );\n+  }\n+\n+  private static MetricFamilySamples buildGauge(String name, String help, double value) {\n+    return new MetricFamilySamples(\n+            name,\n+            Type.GAUGE,\n+            help,\n+            Collections.singletonList(new MetricFamilySamples.Sample(name, EMPTY_LIST, EMPTY_LIST, value)));\n+  }\n+\n+  private MetricFamilySamples buildStatusGauge() {\n+    String name = \"jetty_responses\";\n+    return new MetricFamilySamples(\n+            name,\n+            Type.GAUGE,\n+            \"number of requests with response status\",\n+            Arrays.asList(\n+                    buildStatusSample(name, \"1xx\", statisticsHandler.getResponses1xx()),\n+                    buildStatusSample(name, \"2xx\", statisticsHandler.getResponses2xx()),\n+                    buildStatusSample(name, \"3xx\", statisticsHandler.getResponses3xx()),\n+                    buildStatusSample(name, \"4xx\", statisticsHandler.getResponses4xx()),\n+                    buildStatusSample(name, \"5xx\", statisticsHandler.getResponses5xx())\n+            )\n+    );\n+  }\n+\n+  private static MetricFamilySamples.Sample buildStatusSample(String name, String status, double value) {\n+    return new MetricFamilySamples.Sample(\n+            name,\n+            Collections.singletonList(\"status\"),","path":"simpleclient_jetty/src/main/java/io/prometheus/client/jetty/JettyStatisticsCollector.java","position":77,"original_position":77,"commit_id":"7be1eea2d6a672a38716da7a31c3e0205d627984","original_commit_id":"7be1eea2d6a672a38716da7a31c3e0205d627984","user":{"login":"brian-brazil","id":7115638,"avatar_url":"https://avatars.githubusercontent.com/u/7115638?v=3","gravatar_id":"","url":"https://api.github.com/users/brian-brazil","html_url":"https://github.com/brian-brazil","followers_url":"https://api.github.com/users/brian-brazil/followers","following_url":"https://api.github.com/users/brian-brazil/following{/other_user}","gists_url":"https://api.github.com/users/brian-brazil/gists{/gist_id}","starred_url":"https://api.github.com/users/brian-brazil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brian-brazil/subscriptions","organizations_url":"https://api.github.com/users/brian-brazil/orgs","repos_url":"https://api.github.com/users/brian-brazil/repos","events_url":"https://api.github.com/users/brian-brazil/events{/privacy}","received_events_url":"https://api.github.com/users/brian-brazil/received_events","type":"User","site_admin":false},"body":"We usually call this `code`","created_at":"2016-05-26T06:30:41Z","updated_at":"2016-05-26T06:30:41Z","html_url":"https://github.com/prometheus/client_java/pull/120#discussion_r64696971","pull_request_url":"https://api.github.com/repos/prometheus/client_java/pulls/120","_links":{"self":{"href":"https://api.github.com/repos/prometheus/client_java/pulls/comments/64696971"},"html":{"href":"https://github.com/prometheus/client_java/pull/120#discussion_r64696971"},"pull_request":{"href":"https://api.github.com/repos/prometheus/client_java/pulls/120"}}},"pull_request":{"url":"https://api.github.com/repos/prometheus/client_java/pulls/120","id":71500279,"html_url":"https://github.com/prometheus/client_java/pull/120","diff_url":"https://github.com/prometheus/client_java/pull/120.diff","patch_url":"https://github.com/prometheus/client_java/pull/120.patch","issue_url":"https://api.github.com/repos/prometheus/client_java/issues/120","number":120,"state":"open","locked":false,"title":"Add jetty support","user":{"login":"tokuhirom","id":21084,"avatar_url":"https://avatars.githubusercontent.com/u/21084?v=3","gravatar_id":"","url":"https://api.github.com/users/tokuhirom","html_url":"https://github.com/tokuhirom","followers_url":"https://api.github.com/users/tokuhirom/followers","following_url":"https://api.github.com/users/tokuhirom/following{/other_user}","gists_url":"https://api.github.com/users/tokuhirom/gists{/gist_id}","starred_url":"https://api.github.com/users/tokuhirom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tokuhirom/subscriptions","organizations_url":"https://api.github.com/users/tokuhirom/orgs","repos_url":"https://api.github.com/users/tokuhirom/repos","events_url":"https://api.github.com/users/tokuhirom/events{/privacy}","received_events_url":"https://api.github.com/users/tokuhirom/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-26T04:58:03Z","updated_at":"2016-05-26T06:30:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da00837eaa15e709d97c42d2b50a5c9e8bc5abc8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/client_java/pulls/120/commits","review_comments_url":"https://api.github.com/repos/prometheus/client_java/pulls/120/comments","review_comment_url":"https://api.github.com/repos/prometheus/client_java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prometheus/client_java/issues/120/comments","statuses_url":"https://api.github.com/repos/prometheus/client_java/statuses/7be1eea2d6a672a38716da7a31c3e0205d627984","head":{"label":"tokuhirom:jetty","ref":"jetty","sha":"7be1eea2d6a672a38716da7a31c3e0205d627984","user":{"login":"tokuhirom","id":21084,"avatar_url":"https://avatars.githubusercontent.com/u/21084?v=3","gravatar_id":"","url":"https://api.github.com/users/tokuhirom","html_url":"https://github.com/tokuhirom","followers_url":"https://api.github.com/users/tokuhirom/followers","following_url":"https://api.github.com/users/tokuhirom/following{/other_user}","gists_url":"https://api.github.com/users/tokuhirom/gists{/gist_id}","starred_url":"https://api.github.com/users/tokuhirom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tokuhirom/subscriptions","organizations_url":"https://api.github.com/users/tokuhirom/orgs","repos_url":"https://api.github.com/users/tokuhirom/repos","events_url":"https://api.github.com/users/tokuhirom/events{/privacy}","received_events_url":"https://api.github.com/users/tokuhirom/received_events","type":"User","site_admin":false},"repo":{"id":59168099,"name":"client_java","full_name":"tokuhirom/client_java","owner":{"login":"tokuhirom","id":21084,"avatar_url":"https://avatars.githubusercontent.com/u/21084?v=3","gravatar_id":"","url":"https://api.github.com/users/tokuhirom","html_url":"https://github.com/tokuhirom","followers_url":"https://api.github.com/users/tokuhirom/followers","following_url":"https://api.github.com/users/tokuhirom/following{/other_user}","gists_url":"https://api.github.com/users/tokuhirom/gists{/gist_id}","starred_url":"https://api.github.com/users/tokuhirom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tokuhirom/subscriptions","organizations_url":"https://api.github.com/users/tokuhirom/orgs","repos_url":"https://api.github.com/users/tokuhirom/repos","events_url":"https://api.github.com/users/tokuhirom/events{/privacy}","received_events_url":"https://api.github.com/users/tokuhirom/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tokuhirom/client_java","description":"Prometheus instrumentation library for JVM applications","fork":true,"url":"https://api.github.com/repos/tokuhirom/client_java","forks_url":"https://api.github.com/repos/tokuhirom/client_java/forks","keys_url":"https://api.github.com/repos/tokuhirom/client_java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tokuhirom/client_java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tokuhirom/client_java/teams","hooks_url":"https://api.github.com/repos/tokuhirom/client_java/hooks","issue_events_url":"https://api.github.com/repos/tokuhirom/client_java/issues/events{/number}","events_url":"https://api.github.com/repos/tokuhirom/client_java/events","assignees_url":"https://api.github.com/repos/tokuhirom/client_java/assignees{/user}","branches_url":"https://api.github.com/repos/tokuhirom/client_java/branches{/branch}","tags_url":"https://api.github.com/repos/tokuhirom/client_java/tags","blobs_url":"https://api.github.com/repos/tokuhirom/client_java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tokuhirom/client_java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tokuhirom/client_java/git/refs{/sha}","trees_url":"https://api.github.com/repos/tokuhirom/client_java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tokuhirom/client_java/statuses/{sha}","languages_url":"https://api.github.com/repos/tokuhirom/client_java/languages","stargazers_url":"https://api.github.com/repos/tokuhirom/client_java/stargazers","contributors_url":"https://api.github.com/repos/tokuhirom/client_java/contributors","subscribers_url":"https://api.github.com/repos/tokuhirom/client_java/subscribers","subscription_url":"https://api.github.com/repos/tokuhirom/client_java/subscription","commits_url":"https://api.github.com/repos/tokuhirom/client_java/commits{/sha}","git_commits_url":"https://api.github.com/repos/tokuhirom/client_java/git/commits{/sha}","comments_url":"https://api.github.com/repos/tokuhirom/client_java/comments{/number}","issue_comment_url":"https://api.github.com/repos/tokuhirom/client_java/issues/comments{/number}","contents_url":"https://api.github.com/repos/tokuhirom/client_java/contents/{+path}","compare_url":"https://api.github.com/repos/tokuhirom/client_java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tokuhirom/client_java/merges","archive_url":"https://api.github.com/repos/tokuhirom/client_java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tokuhirom/client_java/downloads","issues_url":"https://api.github.com/repos/tokuhirom/client_java/issues{/number}","pulls_url":"https://api.github.com/repos/tokuhirom/client_java/pulls{/number}","milestones_url":"https://api.github.com/repos/tokuhirom/client_java/milestones{/number}","notifications_url":"https://api.github.com/repos/tokuhirom/client_java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tokuhirom/client_java/labels{/name}","releases_url":"https://api.github.com/repos/tokuhirom/client_java/releases{/id}","deployments_url":"https://api.github.com/repos/tokuhirom/client_java/deployments","created_at":"2016-05-19T02:42:50Z","updated_at":"2016-05-19T02:42:51Z","pushed_at":"2016-05-26T04:57:36Z","git_url":"git://github.com/tokuhirom/client_java.git","ssh_url":"git@github.com:tokuhirom/client_java.git","clone_url":"https://github.com/tokuhirom/client_java.git","svn_url":"https://github.com/tokuhirom/client_java","homepage":"","size":1601,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"prometheus:master","ref":"master","sha":"7ebe34a851d27fa0b9de6bc9de59a9d450846fbf","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":7997879,"name":"client_java","full_name":"prometheus/client_java","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/client_java","description":"Prometheus instrumentation library for JVM applications","fork":false,"url":"https://api.github.com/repos/prometheus/client_java","forks_url":"https://api.github.com/repos/prometheus/client_java/forks","keys_url":"https://api.github.com/repos/prometheus/client_java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/client_java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/client_java/teams","hooks_url":"https://api.github.com/repos/prometheus/client_java/hooks","issue_events_url":"https://api.github.com/repos/prometheus/client_java/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/client_java/events","assignees_url":"https://api.github.com/repos/prometheus/client_java/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/client_java/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/client_java/tags","blobs_url":"https://api.github.com/repos/prometheus/client_java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/client_java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/client_java/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/client_java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/client_java/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/client_java/languages","stargazers_url":"https://api.github.com/repos/prometheus/client_java/stargazers","contributors_url":"https://api.github.com/repos/prometheus/client_java/contributors","subscribers_url":"https://api.github.com/repos/prometheus/client_java/subscribers","subscription_url":"https://api.github.com/repos/prometheus/client_java/subscription","commits_url":"https://api.github.com/repos/prometheus/client_java/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/client_java/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/client_java/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/client_java/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/client_java/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/client_java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/client_java/merges","archive_url":"https://api.github.com/repos/prometheus/client_java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/client_java/downloads","issues_url":"https://api.github.com/repos/prometheus/client_java/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/client_java/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/client_java/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/client_java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/client_java/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/client_java/releases{/id}","deployments_url":"https://api.github.com/repos/prometheus/client_java/deployments","created_at":"2013-02-03T22:55:49Z","updated_at":"2016-05-20T09:44:25Z","pushed_at":"2016-05-26T04:58:05Z","git_url":"git://github.com/prometheus/client_java.git","ssh_url":"git@github.com:prometheus/client_java.git","clone_url":"https://github.com/prometheus/client_java.git","svn_url":"https://github.com/prometheus/client_java","homepage":"","size":1742,"stargazers_count":40,"watchers_count":40,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":46,"mirror_url":null,"open_issues_count":12,"forks":46,"open_issues":12,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/client_java/pulls/120"},"html":{"href":"https://github.com/prometheus/client_java/pull/120"},"issue":{"href":"https://api.github.com/repos/prometheus/client_java/issues/120"},"comments":{"href":"https://api.github.com/repos/prometheus/client_java/issues/120/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/client_java/pulls/120/comments"},"review_comment":{"href":"https://api.github.com/repos/prometheus/client_java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prometheus/client_java/pulls/120/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/client_java/statuses/7be1eea2d6a672a38716da7a31c3e0205d627984"}}}}
{"actor":{"display_login":"brian-brazil"}}