{"action":"created","comment":{"url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/comments/85541307","pull_request_review_id":6252941,"id":85541307,"diff_hunk":"@@ -0,0 +1,73 @@\n+/*\n+ * (C) Copyright 2016 Nuxeo SA (http://nuxeo.com/) and others.\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+ * Contributors:\n+ *     Kevin Leturc\n+ */\n+package org.nuxeo.ecm.core.storage.dbs;\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+\n+import com.codahale.metrics.Gauge;\n+import com.codahale.metrics.Metric;\n+import com.codahale.metrics.MetricRegistry;\n+import com.codahale.metrics.MetricSet;\n+import com.google.common.cache.Cache;\n+\n+/**\n+ * Wrapper used to wrap the Guava cache's statistics into Gauges in order to report them via Codahale Metrics.\n+ *\n+ * @since 8.10\n+ */\n+public class GuavaCacheMetric implements MetricSet {\n+\n+    private Map<String, Metric> metrics = new HashMap<>();\n+\n+    private GuavaCacheMetric() {\n+    }\n+\n+    @Override\n+    public Map<String, Metric> getMetrics() {\n+        return metrics;\n+    }\n+\n+    private <T> void putMetrics(String gaugeName, Gauge<T> gauge, String name, String... names) {\n+        List<String> namesList = new ArrayList<>(Arrays.asList(names));\n+        namesList.add(gaugeName);\n+        metrics.put(MetricRegistry.name(name, namesList.toArray(new String[namesList.size()])), gauge);\n+    }\n+\n+    public static MetricSet of(Cache cache, String name, String... names) {\n+        GuavaCacheMetric metrics = new GuavaCacheMetric();\n+        metrics.putMetrics(\"averageLoadPenalty\", () -> cache.stats().averageLoadPenalty(), name, names);\n+        metrics.putMetrics(\"evictionCount\", () -> cache.stats().evictionCount(), name, names);\n+        metrics.putMetrics(\"hitCount\", () -> cache.stats().hitCount(), name, names);\n+        metrics.putMetrics(\"hitRate\", () -> cache.stats().hitRate(), name, names);\n+        metrics.putMetrics(\"loadCount\", () -> cache.stats().loadCount(), name, names);\n+        metrics.putMetrics(\"loadExceptionCount\", () -> cache.stats().loadExceptionCount(), name, names);\n+        metrics.putMetrics(\"loadExceptionRate\", () -> cache.stats().loadExceptionRate(), name, names);\n+        metrics.putMetrics(\"loadSuccessCount\", () -> cache.stats().loadSuccessCount(), name, names);\n+        metrics.putMetrics(\"missCount\", () -> cache.stats().missCount(), name, names);\n+        metrics.putMetrics(\"missRate\", () -> cache.stats().missRate(), name, names);\n+        metrics.putMetrics(\"requestCount\", () -> cache.stats().requestCount(), name, names);\n+        metrics.putMetrics(\"totalLoadTime\", () -> cache.stats().totalLoadTime(), name, names);\n+        return metrics;","path":"nuxeo-core/nuxeo-core-storage-dbs/src/main/java/org/nuxeo/ecm/core/storage/dbs/GuavaCacheMetric.java","position":70,"original_position":70,"commit_id":"3ccaea136ce9154b5562ce93de88f38bc9257d65","original_commit_id":"3ccaea136ce9154b5562ce93de88f38bc9257d65","user":{"login":"kevinleturc","id":3491744,"avatar_url":"https://avatars.githubusercontent.com/u/3491744?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinleturc","html_url":"https://github.com/kevinleturc","followers_url":"https://api.github.com/users/kevinleturc/followers","following_url":"https://api.github.com/users/kevinleturc/following{/other_user}","gists_url":"https://api.github.com/users/kevinleturc/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinleturc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinleturc/subscriptions","organizations_url":"https://api.github.com/users/kevinleturc/orgs","repos_url":"https://api.github.com/users/kevinleturc/repos","events_url":"https://api.github.com/users/kevinleturc/events{/privacy}","received_events_url":"https://api.github.com/users/kevinleturc/received_events","type":"User","site_admin":false},"body":"Will change that","created_at":"2016-10-28T14:30:21Z","updated_at":"2016-10-28T14:30:21Z","html_url":"https://github.com/nuxeo/nuxeo/pull/311#discussion_r85541307","pull_request_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/311","_links":{"self":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/comments/85541307"},"html":{"href":"https://github.com/nuxeo/nuxeo/pull/311#discussion_r85541307"},"pull_request":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/311"}}},"pull_request":{"url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/311","id":91353982,"html_url":"https://github.com/nuxeo/nuxeo/pull/311","diff_url":"https://github.com/nuxeo/nuxeo/pull/311.diff","patch_url":"https://github.com/nuxeo/nuxeo/pull/311.patch","issue_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/311","number":311,"state":"open","locked":false,"title":"feature-NXP-20640-dbs-cache","user":{"login":"kevinleturc","id":3491744,"avatar_url":"https://avatars.githubusercontent.com/u/3491744?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinleturc","html_url":"https://github.com/kevinleturc","followers_url":"https://api.github.com/users/kevinleturc/followers","following_url":"https://api.github.com/users/kevinleturc/following{/other_user}","gists_url":"https://api.github.com/users/kevinleturc/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinleturc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinleturc/subscriptions","organizations_url":"https://api.github.com/users/kevinleturc/orgs","repos_url":"https://api.github.com/users/kevinleturc/repos","events_url":"https://api.github.com/users/kevinleturc/events{/privacy}","received_events_url":"https://api.github.com/users/kevinleturc/received_events","type":"User","site_admin":false},"body":"PR created manually, but t&p succeed https://qa.nuxeo.org/jenkins/job/TestAndPush/job/ondemand-testandpush-kleturc/65/","created_at":"2016-10-28T09:59:07Z","updated_at":"2016-10-28T14:30:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e60260b46d92de1d7749eddacfa94813add82931","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/311/commits","review_comments_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/311/comments","review_comment_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/311/comments","statuses_url":"https://api.github.com/repos/nuxeo/nuxeo/statuses/3ccaea136ce9154b5562ce93de88f38bc9257d65","head":{"label":"nuxeo:feature-NXP-20640-dbs-cache","ref":"feature-NXP-20640-dbs-cache","sha":"3ccaea136ce9154b5562ce93de88f38bc9257d65","user":{"login":"nuxeo","id":460607,"avatar_url":"https://avatars.githubusercontent.com/u/460607?v=3","gravatar_id":"","url":"https://api.github.com/users/nuxeo","html_url":"https://github.com/nuxeo","followers_url":"https://api.github.com/users/nuxeo/followers","following_url":"https://api.github.com/users/nuxeo/following{/other_user}","gists_url":"https://api.github.com/users/nuxeo/gists{/gist_id}","starred_url":"https://api.github.com/users/nuxeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuxeo/subscriptions","organizations_url":"https://api.github.com/users/nuxeo/orgs","repos_url":"https://api.github.com/users/nuxeo/repos","events_url":"https://api.github.com/users/nuxeo/events{/privacy}","received_events_url":"https://api.github.com/users/nuxeo/received_events","type":"Organization","site_admin":false},"repo":{"id":2988101,"name":"nuxeo","full_name":"nuxeo/nuxeo","owner":{"login":"nuxeo","id":460607,"avatar_url":"https://avatars.githubusercontent.com/u/460607?v=3","gravatar_id":"","url":"https://api.github.com/users/nuxeo","html_url":"https://github.com/nuxeo","followers_url":"https://api.github.com/users/nuxeo/followers","following_url":"https://api.github.com/users/nuxeo/following{/other_user}","gists_url":"https://api.github.com/users/nuxeo/gists{/gist_id}","starred_url":"https://api.github.com/users/nuxeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuxeo/subscriptions","organizations_url":"https://api.github.com/users/nuxeo/orgs","repos_url":"https://api.github.com/users/nuxeo/repos","events_url":"https://api.github.com/users/nuxeo/events{/privacy}","received_events_url":"https://api.github.com/users/nuxeo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nuxeo/nuxeo","description":"Content management platform to build modern business applications","fork":false,"url":"https://api.github.com/repos/nuxeo/nuxeo","forks_url":"https://api.github.com/repos/nuxeo/nuxeo/forks","keys_url":"https://api.github.com/repos/nuxeo/nuxeo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nuxeo/nuxeo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nuxeo/nuxeo/teams","hooks_url":"https://api.github.com/repos/nuxeo/nuxeo/hooks","issue_events_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/events{/number}","events_url":"https://api.github.com/repos/nuxeo/nuxeo/events","assignees_url":"https://api.github.com/repos/nuxeo/nuxeo/assignees{/user}","branches_url":"https://api.github.com/repos/nuxeo/nuxeo/branches{/branch}","tags_url":"https://api.github.com/repos/nuxeo/nuxeo/tags","blobs_url":"https://api.github.com/repos/nuxeo/nuxeo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nuxeo/nuxeo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nuxeo/nuxeo/git/refs{/sha}","trees_url":"https://api.github.com/repos/nuxeo/nuxeo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nuxeo/nuxeo/statuses/{sha}","languages_url":"https://api.github.com/repos/nuxeo/nuxeo/languages","stargazers_url":"https://api.github.com/repos/nuxeo/nuxeo/stargazers","contributors_url":"https://api.github.com/repos/nuxeo/nuxeo/contributors","subscribers_url":"https://api.github.com/repos/nuxeo/nuxeo/subscribers","subscription_url":"https://api.github.com/repos/nuxeo/nuxeo/subscription","commits_url":"https://api.github.com/repos/nuxeo/nuxeo/commits{/sha}","git_commits_url":"https://api.github.com/repos/nuxeo/nuxeo/git/commits{/sha}","comments_url":"https://api.github.com/repos/nuxeo/nuxeo/comments{/number}","issue_comment_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/comments{/number}","contents_url":"https://api.github.com/repos/nuxeo/nuxeo/contents/{+path}","compare_url":"https://api.github.com/repos/nuxeo/nuxeo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nuxeo/nuxeo/merges","archive_url":"https://api.github.com/repos/nuxeo/nuxeo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nuxeo/nuxeo/downloads","issues_url":"https://api.github.com/repos/nuxeo/nuxeo/issues{/number}","pulls_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls{/number}","milestones_url":"https://api.github.com/repos/nuxeo/nuxeo/milestones{/number}","notifications_url":"https://api.github.com/repos/nuxeo/nuxeo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nuxeo/nuxeo/labels{/name}","releases_url":"https://api.github.com/repos/nuxeo/nuxeo/releases{/id}","deployments_url":"https://api.github.com/repos/nuxeo/nuxeo/deployments","created_at":"2011-12-15T14:35:41Z","updated_at":"2016-10-25T10:25:50Z","pushed_at":"2016-10-28T14:16:09Z","git_url":"git://github.com/nuxeo/nuxeo.git","ssh_url":"git@github.com:nuxeo/nuxeo.git","clone_url":"https://github.com/nuxeo/nuxeo.git","svn_url":"https://github.com/nuxeo/nuxeo","homepage":"http://www.nuxeo.com","size":253459,"stargazers_count":122,"watchers_count":122,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":90,"mirror_url":null,"open_issues_count":18,"forks":90,"open_issues":18,"watchers":122,"default_branch":"master"}},"base":{"label":"nuxeo:master","ref":"master","sha":"e0cb90685b1beb590e7ed4f8d54793045886008c","user":{"login":"nuxeo","id":460607,"avatar_url":"https://avatars.githubusercontent.com/u/460607?v=3","gravatar_id":"","url":"https://api.github.com/users/nuxeo","html_url":"https://github.com/nuxeo","followers_url":"https://api.github.com/users/nuxeo/followers","following_url":"https://api.github.com/users/nuxeo/following{/other_user}","gists_url":"https://api.github.com/users/nuxeo/gists{/gist_id}","starred_url":"https://api.github.com/users/nuxeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuxeo/subscriptions","organizations_url":"https://api.github.com/users/nuxeo/orgs","repos_url":"https://api.github.com/users/nuxeo/repos","events_url":"https://api.github.com/users/nuxeo/events{/privacy}","received_events_url":"https://api.github.com/users/nuxeo/received_events","type":"Organization","site_admin":false},"repo":{"id":2988101,"name":"nuxeo","full_name":"nuxeo/nuxeo","owner":{"login":"nuxeo","id":460607,"avatar_url":"https://avatars.githubusercontent.com/u/460607?v=3","gravatar_id":"","url":"https://api.github.com/users/nuxeo","html_url":"https://github.com/nuxeo","followers_url":"https://api.github.com/users/nuxeo/followers","following_url":"https://api.github.com/users/nuxeo/following{/other_user}","gists_url":"https://api.github.com/users/nuxeo/gists{/gist_id}","starred_url":"https://api.github.com/users/nuxeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuxeo/subscriptions","organizations_url":"https://api.github.com/users/nuxeo/orgs","repos_url":"https://api.github.com/users/nuxeo/repos","events_url":"https://api.github.com/users/nuxeo/events{/privacy}","received_events_url":"https://api.github.com/users/nuxeo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nuxeo/nuxeo","description":"Content management platform to build modern business applications","fork":false,"url":"https://api.github.com/repos/nuxeo/nuxeo","forks_url":"https://api.github.com/repos/nuxeo/nuxeo/forks","keys_url":"https://api.github.com/repos/nuxeo/nuxeo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nuxeo/nuxeo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nuxeo/nuxeo/teams","hooks_url":"https://api.github.com/repos/nuxeo/nuxeo/hooks","issue_events_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/events{/number}","events_url":"https://api.github.com/repos/nuxeo/nuxeo/events","assignees_url":"https://api.github.com/repos/nuxeo/nuxeo/assignees{/user}","branches_url":"https://api.github.com/repos/nuxeo/nuxeo/branches{/branch}","tags_url":"https://api.github.com/repos/nuxeo/nuxeo/tags","blobs_url":"https://api.github.com/repos/nuxeo/nuxeo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nuxeo/nuxeo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nuxeo/nuxeo/git/refs{/sha}","trees_url":"https://api.github.com/repos/nuxeo/nuxeo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nuxeo/nuxeo/statuses/{sha}","languages_url":"https://api.github.com/repos/nuxeo/nuxeo/languages","stargazers_url":"https://api.github.com/repos/nuxeo/nuxeo/stargazers","contributors_url":"https://api.github.com/repos/nuxeo/nuxeo/contributors","subscribers_url":"https://api.github.com/repos/nuxeo/nuxeo/subscribers","subscription_url":"https://api.github.com/repos/nuxeo/nuxeo/subscription","commits_url":"https://api.github.com/repos/nuxeo/nuxeo/commits{/sha}","git_commits_url":"https://api.github.com/repos/nuxeo/nuxeo/git/commits{/sha}","comments_url":"https://api.github.com/repos/nuxeo/nuxeo/comments{/number}","issue_comment_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/comments{/number}","contents_url":"https://api.github.com/repos/nuxeo/nuxeo/contents/{+path}","compare_url":"https://api.github.com/repos/nuxeo/nuxeo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nuxeo/nuxeo/merges","archive_url":"https://api.github.com/repos/nuxeo/nuxeo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nuxeo/nuxeo/downloads","issues_url":"https://api.github.com/repos/nuxeo/nuxeo/issues{/number}","pulls_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls{/number}","milestones_url":"https://api.github.com/repos/nuxeo/nuxeo/milestones{/number}","notifications_url":"https://api.github.com/repos/nuxeo/nuxeo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nuxeo/nuxeo/labels{/name}","releases_url":"https://api.github.com/repos/nuxeo/nuxeo/releases{/id}","deployments_url":"https://api.github.com/repos/nuxeo/nuxeo/deployments","created_at":"2011-12-15T14:35:41Z","updated_at":"2016-10-25T10:25:50Z","pushed_at":"2016-10-28T14:16:09Z","git_url":"git://github.com/nuxeo/nuxeo.git","ssh_url":"git@github.com:nuxeo/nuxeo.git","clone_url":"https://github.com/nuxeo/nuxeo.git","svn_url":"https://github.com/nuxeo/nuxeo","homepage":"http://www.nuxeo.com","size":253459,"stargazers_count":122,"watchers_count":122,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":90,"mirror_url":null,"open_issues_count":18,"forks":90,"open_issues":18,"watchers":122,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/311"},"html":{"href":"https://github.com/nuxeo/nuxeo/pull/311"},"issue":{"href":"https://api.github.com/repos/nuxeo/nuxeo/issues/311"},"comments":{"href":"https://api.github.com/repos/nuxeo/nuxeo/issues/311/comments"},"review_comments":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/311/comments"},"review_comment":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/311/commits"},"statuses":{"href":"https://api.github.com/repos/nuxeo/nuxeo/statuses/3ccaea136ce9154b5562ce93de88f38bc9257d65"}}}}
{"actor":{"display_login":"kevinleturc"}}