{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-druid/pulls/comments/240246196","pull_request_review_id":183230523,"id":240246196,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDI0NjE5Ng==","diff_hunk":"@@ -0,0 +1,95 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  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,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.apache.druid.java.util.metrics;\n+\n+import org.apache.druid.java.util.common.logger.Logger;\n+import java.lang.management.ManagementFactory;\n+import java.lang.management.ThreadMXBean;\n+import java.lang.reflect.Method;\n+import java.util.Arrays;\n+import java.util.HashMap;\n+import java.util.Map;\n+import java.util.Optional;\n+import java.util.stream.Collectors;\n+\n+class AllocationMetricCollector\n+{\n+  private static final Logger log = new Logger(AllocationMetricCollector.class);\n+  private Method getThreadAllocatedBytes;\n+  private ThreadMXBean threadMXBean;\n+  private Map<Long, Long> previousResults;\n+  private boolean initialized = false;\n+\n+  AllocationMetricCollector()\n+  {\n+    try {\n+      // no Java official public API is present for the following method, so using reflection\n+      threadMXBean = ManagementFactory.getThreadMXBean();\n+      getThreadAllocatedBytes = threadMXBean.getClass().getMethod(\"getThreadAllocatedBytes\", long[].class);\n+      getThreadAllocatedBytes.setAccessible(true);\n+      long[] allThreadIds = threadMXBean.getAllThreadIds();\n+      long[] bytes = (long[]) getThreadAllocatedBytes.invoke(threadMXBean, (Object) allThreadIds);\n+\n+      previousResults = new HashMap<>(allThreadIds.length);\n+      for (int i = 0; i < allThreadIds.length; i++) {\n+        long threadId = allThreadIds[i];\n+        previousResults.put(threadId, bytes[i]);\n+\n+      }\n+      initialized = true;\n+    }\n+    catch (Exception e) {","path":"core/src/main/java/org/apache/druid/java/util/metrics/AllocationMetricCollector.java","position":58,"original_position":58,"commit_id":"51985351d1814ed47e26555c350121544b49a545","original_commit_id":"51985351d1814ed47e26555c350121544b49a545","user":{"login":"egor-ryashin","id":14215045,"node_id":"MDQ6VXNlcjE0MjE1MDQ1","avatar_url":"https://avatars1.githubusercontent.com/u/14215045?v=4","gravatar_id":"","url":"https://api.github.com/users/egor-ryashin","html_url":"https://github.com/egor-ryashin","followers_url":"https://api.github.com/users/egor-ryashin/followers","following_url":"https://api.github.com/users/egor-ryashin/following{/other_user}","gists_url":"https://api.github.com/users/egor-ryashin/gists{/gist_id}","starred_url":"https://api.github.com/users/egor-ryashin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egor-ryashin/subscriptions","organizations_url":"https://api.github.com/users/egor-ryashin/orgs","repos_url":"https://api.github.com/users/egor-ryashin/repos","events_url":"https://api.github.com/users/egor-ryashin/events{/privacy}","received_events_url":"https://api.github.com/users/egor-ryashin/received_events","type":"User","site_admin":false},"body":"There is a whole lot of runtime exception types which can be thrown by reflection API (ie IllegalArgumentException and NPE)","created_at":"2018-12-10T15:06:51Z","updated_at":"2018-12-10T15:06:52Z","html_url":"https://github.com/apache/incubator-druid/pull/6710#discussion_r240246196","pull_request_url":"https://api.github.com/repos/apache/incubator-druid/pulls/6710","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/comments/240246196"},"html":{"href":"https://github.com/apache/incubator-druid/pull/6710#discussion_r240246196"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/6710"}},"in_reply_to_id":239173250},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-druid/pulls/6710","id":236256622,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM2MjU2NjIy","html_url":"https://github.com/apache/incubator-druid/pull/6710","diff_url":"https://github.com/apache/incubator-druid/pull/6710.diff","patch_url":"https://github.com/apache/incubator-druid/pull/6710.patch","issue_url":"https://api.github.com/repos/apache/incubator-druid/issues/6710","number":6710,"state":"open","locked":false,"title":"Added an allocation rate metric #6604","user":{"login":"egor-ryashin","id":14215045,"node_id":"MDQ6VXNlcjE0MjE1MDQ1","avatar_url":"https://avatars1.githubusercontent.com/u/14215045?v=4","gravatar_id":"","url":"https://api.github.com/users/egor-ryashin","html_url":"https://github.com/egor-ryashin","followers_url":"https://api.github.com/users/egor-ryashin/followers","following_url":"https://api.github.com/users/egor-ryashin/following{/other_user}","gists_url":"https://api.github.com/users/egor-ryashin/gists{/gist_id}","starred_url":"https://api.github.com/users/egor-ryashin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egor-ryashin/subscriptions","organizations_url":"https://api.github.com/users/egor-ryashin/orgs","repos_url":"https://api.github.com/users/egor-ryashin/repos","events_url":"https://api.github.com/users/egor-ryashin/events{/privacy}","received_events_url":"https://api.github.com/users/egor-ryashin/received_events","type":"User","site_admin":false},"body":"Addressing #6604","created_at":"2018-12-05T17:17:07Z","updated_at":"2018-12-10T15:06:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"82034031382a02b7b492e8f563c3e77c1b691882","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":612479291,"node_id":"MDU6TGFiZWw2MTI0NzkyOTE=","url":"https://api.github.com/repos/apache/incubator-druid/labels/Area%20-%20Metrics/Event%20Emitting","name":"Area - Metrics/Event Emitting","color":"fef2c0","default":false},{"id":222509152,"node_id":"MDU6TGFiZWwyMjI1MDkxNTI=","url":"https://api.github.com/repos/apache/incubator-druid/labels/Area%20-%20Operations","name":"Area - Operations","color":"fef2c0","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-druid/pulls/6710/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-druid/pulls/6710/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-druid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-druid/issues/6710/comments","statuses_url":"https://api.github.com/repos/apache/incubator-druid/statuses/51985351d1814ed47e26555c350121544b49a545","head":{"label":"metamx:feature-6604","ref":"feature-6604","sha":"51985351d1814ed47e26555c350121544b49a545","user":{"login":"metamx","id":299329,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5OTMyOQ==","avatar_url":"https://avatars1.githubusercontent.com/u/299329?v=4","gravatar_id":"","url":"https://api.github.com/users/metamx","html_url":"https://github.com/metamx","followers_url":"https://api.github.com/users/metamx/followers","following_url":"https://api.github.com/users/metamx/following{/other_user}","gists_url":"https://api.github.com/users/metamx/gists{/gist_id}","starred_url":"https://api.github.com/users/metamx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metamx/subscriptions","organizations_url":"https://api.github.com/users/metamx/orgs","repos_url":"https://api.github.com/users/metamx/repos","events_url":"https://api.github.com/users/metamx/events{/privacy}","received_events_url":"https://api.github.com/users/metamx/received_events","type":"Organization","site_admin":false},"repo":{"id":28248872,"node_id":"MDEwOlJlcG9zaXRvcnkyODI0ODg3Mg==","name":"druid","full_name":"metamx/druid","private":false,"owner":{"login":"metamx","id":299329,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5OTMyOQ==","avatar_url":"https://avatars1.githubusercontent.com/u/299329?v=4","gravatar_id":"","url":"https://api.github.com/users/metamx","html_url":"https://github.com/metamx","followers_url":"https://api.github.com/users/metamx/followers","following_url":"https://api.github.com/users/metamx/following{/other_user}","gists_url":"https://api.github.com/users/metamx/gists{/gist_id}","starred_url":"https://api.github.com/users/metamx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metamx/subscriptions","organizations_url":"https://api.github.com/users/metamx/orgs","repos_url":"https://api.github.com/users/metamx/repos","events_url":"https://api.github.com/users/metamx/events{/privacy}","received_events_url":"https://api.github.com/users/metamx/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/metamx/druid","description":"Real²time Exploratory Analytics on Large Datasets","fork":true,"url":"https://api.github.com/repos/metamx/druid","forks_url":"https://api.github.com/repos/metamx/druid/forks","keys_url":"https://api.github.com/repos/metamx/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metamx/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metamx/druid/teams","hooks_url":"https://api.github.com/repos/metamx/druid/hooks","issue_events_url":"https://api.github.com/repos/metamx/druid/issues/events{/number}","events_url":"https://api.github.com/repos/metamx/druid/events","assignees_url":"https://api.github.com/repos/metamx/druid/assignees{/user}","branches_url":"https://api.github.com/repos/metamx/druid/branches{/branch}","tags_url":"https://api.github.com/repos/metamx/druid/tags","blobs_url":"https://api.github.com/repos/metamx/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metamx/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metamx/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/metamx/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metamx/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/metamx/druid/languages","stargazers_url":"https://api.github.com/repos/metamx/druid/stargazers","contributors_url":"https://api.github.com/repos/metamx/druid/contributors","subscribers_url":"https://api.github.com/repos/metamx/druid/subscribers","subscription_url":"https://api.github.com/repos/metamx/druid/subscription","commits_url":"https://api.github.com/repos/metamx/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/metamx/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/metamx/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/metamx/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/metamx/druid/contents/{+path}","compare_url":"https://api.github.com/repos/metamx/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metamx/druid/merges","archive_url":"https://api.github.com/repos/metamx/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metamx/druid/downloads","issues_url":"https://api.github.com/repos/metamx/druid/issues{/number}","pulls_url":"https://api.github.com/repos/metamx/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/metamx/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/metamx/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metamx/druid/labels{/name}","releases_url":"https://api.github.com/repos/metamx/druid/releases{/id}","deployments_url":"https://api.github.com/repos/metamx/druid/deployments","created_at":"2014-12-19T22:30:25Z","updated_at":"2018-11-11T18:29:24Z","pushed_at":"2018-12-05T16:59:44Z","git_url":"git://github.com/metamx/druid.git","ssh_url":"git@github.com:metamx/druid.git","clone_url":"https://github.com/metamx/druid.git","svn_url":"https://github.com/metamx/druid","homepage":"http://druid.io","size":154795,"stargazers_count":105,"watchers_count":105,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":33,"open_issues":2,"watchers":105,"default_branch":"0.12.1-mmx"}},"base":{"label":"apache:master","ref":"master","sha":"607339003b2c31ff8d2a047d4afdc563f4d05675","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":6358188,"node_id":"MDEwOlJlcG9zaXRvcnk2MzU4MTg4","name":"incubator-druid","full_name":"apache/incubator-druid","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/apache/incubator-druid","description":"Apache Druid (Incubating) - Column oriented distributed data store ideal for powering interactive applications","fork":false,"url":"https://api.github.com/repos/apache/incubator-druid","forks_url":"https://api.github.com/repos/apache/incubator-druid/forks","keys_url":"https://api.github.com/repos/apache/incubator-druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-druid/teams","hooks_url":"https://api.github.com/repos/apache/incubator-druid/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-druid/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-druid/events","assignees_url":"https://api.github.com/repos/apache/incubator-druid/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-druid/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-druid/tags","blobs_url":"https://api.github.com/repos/apache/incubator-druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-druid/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-druid/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-druid/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-druid/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-druid/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-druid/subscription","commits_url":"https://api.github.com/repos/apache/incubator-druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-druid/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-druid/merges","archive_url":"https://api.github.com/repos/apache/incubator-druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-druid/downloads","issues_url":"https://api.github.com/repos/apache/incubator-druid/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-druid/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-druid/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-druid/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-druid/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-druid/deployments","created_at":"2012-10-23T19:08:07Z","updated_at":"2018-12-10T13:43:46Z","pushed_at":"2018-12-10T12:40:16Z","git_url":"git://github.com/apache/incubator-druid.git","ssh_url":"git@github.com:apache/incubator-druid.git","clone_url":"https://github.com/apache/incubator-druid.git","svn_url":"https://github.com/apache/incubator-druid","homepage":"http://druid.io","size":153150,"stargazers_count":7326,"watchers_count":7326,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1801,"mirror_url":null,"archived":false,"open_issues_count":1203,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1801,"open_issues":1203,"watchers":7326,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/6710"},"html":{"href":"https://github.com/apache/incubator-druid/pull/6710"},"issue":{"href":"https://api.github.com/repos/apache/incubator-druid/issues/6710"},"comments":{"href":"https://api.github.com/repos/apache/incubator-druid/issues/6710/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/6710/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/6710/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-druid/statuses/51985351d1814ed47e26555c350121544b49a545"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"egor-ryashin"}}