{"action":"created","comment":{"url":"https://api.github.com/repos/outbrain/ob1k/pulls/comments/48416779","id":48416779,"diff_hunk":"@@ -0,0 +1,99 @@\n+package com.outbrain.ob1k.cache.metrics;\n+\n+import java.util.Map;\n+import java.util.concurrent.ExecutionException;\n+\n+import com.google.common.base.Preconditions;\n+import com.google.common.collect.Iterables;\n+import com.outbrain.ob1k.cache.EntryMapper;\n+import com.outbrain.ob1k.cache.TypedCache;\n+import com.outbrain.ob1k.concurrent.ComposableFuture;\n+import com.outbrain.ob1k.concurrent.handlers.SuccessHandler;\n+import com.outbrain.swinfra.metrics.api.Counter;\n+import com.outbrain.swinfra.metrics.api.MetricFactory;\n+\n+/**\n+ * A decorator adding metric monitoring to TypedCache.\n+ *\n+ * @author hunchback\n+ */\n+public class MonitoringCacheDelegate<K, V> implements TypedCache<K, V> {\n+  protected final TypedCache<K, V> delegate;\n+\n+  /* interface call metrics */\n+  private final AsyncOperationMetrics<V> getAsyncMetrics;\n+  private final AsyncOperationMetrics<Map<K, V>> getBulkAsyncMetrics;\n+  private final AsyncOperationMetrics<Boolean> setAsyncMetrics;\n+  private final AsyncOperationMetrics<Map<K, Boolean>> setBulkAsyncMetrics;\n+  private final AsyncOperationMetrics<Boolean> deleteAsyncMetrics;\n+\n+  /* cache metrics */\n+  private final Counter total;\n+  private final Counter hits;\n+\n+  private final SuccessHandler<V, V> getCacheMetricsUpdater = new SuccessHandler<V, V>() {\n+    @Override\n+    public V handle(final V result) throws ExecutionException {\n+      total.inc();\n+      if (result != null) {\n+        hits.inc();\n+      }\n+      return result;\n+    }\n+  };\n+\n+  public MonitoringCacheDelegate(final TypedCache<K, V> delegate, String cacheName, final MetricFactory metricFactory) {\n+    this.delegate = Preconditions.checkNotNull(delegate);","path":"ob1k-cache/src/main/java/com/outbrain/ob1k/cache/metrics/MonitoringCacheDelegate.java","position":46,"original_position":46,"commit_id":"721457dca373bc6f0efd49054fa6e4814ab4fdac","original_commit_id":"721457dca373bc6f0efd49054fa6e4814ab4fdac","user":{"login":"hunchback","id":2760739,"avatar_url":"https://avatars.githubusercontent.com/u/2760739?v=3","gravatar_id":"","url":"https://api.github.com/users/hunchback","html_url":"https://github.com/hunchback","followers_url":"https://api.github.com/users/hunchback/followers","following_url":"https://api.github.com/users/hunchback/following{/other_user}","gists_url":"https://api.github.com/users/hunchback/gists{/gist_id}","starred_url":"https://api.github.com/users/hunchback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunchback/subscriptions","organizations_url":"https://api.github.com/users/hunchback/orgs","repos_url":"https://api.github.com/users/hunchback/repos","events_url":"https://api.github.com/users/hunchback/events{/privacy}","received_events_url":"https://api.github.com/users/hunchback/received_events","type":"User","site_admin":false},"body":"corrected","created_at":"2015-12-24T14:37:08Z","updated_at":"2015-12-24T14:37:08Z","html_url":"https://github.com/outbrain/ob1k/pull/29#discussion_r48416779","pull_request_url":"https://api.github.com/repos/outbrain/ob1k/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/outbrain/ob1k/pulls/comments/48416779"},"html":{"href":"https://github.com/outbrain/ob1k/pull/29#discussion_r48416779"},"pull_request":{"href":"https://api.github.com/repos/outbrain/ob1k/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/outbrain/ob1k/pulls/29","id":54013776,"html_url":"https://github.com/outbrain/ob1k/pull/29","diff_url":"https://github.com/outbrain/ob1k/pull/29.diff","patch_url":"https://github.com/outbrain/ob1k/pull/29.patch","issue_url":"https://api.github.com/repos/outbrain/ob1k/issues/29","number":29,"state":"open","locked":false,"title":"[ob1k-cache] added monitoring cache delegate (plus tests)","user":{"login":"hunchback","id":2760739,"avatar_url":"https://avatars.githubusercontent.com/u/2760739?v=3","gravatar_id":"","url":"https://api.github.com/users/hunchback","html_url":"https://github.com/hunchback","followers_url":"https://api.github.com/users/hunchback/followers","following_url":"https://api.github.com/users/hunchback/following{/other_user}","gists_url":"https://api.github.com/users/hunchback/gists{/gist_id}","starred_url":"https://api.github.com/users/hunchback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunchback/subscriptions","organizations_url":"https://api.github.com/users/hunchback/orgs","repos_url":"https://api.github.com/users/hunchback/repos","events_url":"https://api.github.com/users/hunchback/events{/privacy}","received_events_url":"https://api.github.com/users/hunchback/received_events","type":"User","site_admin":false},"body":"including:\r\n- monitoring cache delegate\r\n- tested with memcacheClient\r\n- added unit tests","created_at":"2015-12-17T18:33:58Z","updated_at":"2015-12-24T14:37:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"90d1982403f1402fbcce6a3af01ea6e6392061af","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/outbrain/ob1k/pulls/29/commits","review_comments_url":"https://api.github.com/repos/outbrain/ob1k/pulls/29/comments","review_comment_url":"https://api.github.com/repos/outbrain/ob1k/pulls/comments{/number}","comments_url":"https://api.github.com/repos/outbrain/ob1k/issues/29/comments","statuses_url":"https://api.github.com/repos/outbrain/ob1k/statuses/721457dca373bc6f0efd49054fa6e4814ab4fdac","head":{"label":"hunchback:master","ref":"master","sha":"721457dca373bc6f0efd49054fa6e4814ab4fdac","user":{"login":"hunchback","id":2760739,"avatar_url":"https://avatars.githubusercontent.com/u/2760739?v=3","gravatar_id":"","url":"https://api.github.com/users/hunchback","html_url":"https://github.com/hunchback","followers_url":"https://api.github.com/users/hunchback/followers","following_url":"https://api.github.com/users/hunchback/following{/other_user}","gists_url":"https://api.github.com/users/hunchback/gists{/gist_id}","starred_url":"https://api.github.com/users/hunchback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunchback/subscriptions","organizations_url":"https://api.github.com/users/hunchback/orgs","repos_url":"https://api.github.com/users/hunchback/repos","events_url":"https://api.github.com/users/hunchback/events{/privacy}","received_events_url":"https://api.github.com/users/hunchback/received_events","type":"User","site_admin":false},"repo":{"id":46799884,"name":"ob1k","full_name":"hunchback/ob1k","owner":{"login":"hunchback","id":2760739,"avatar_url":"https://avatars.githubusercontent.com/u/2760739?v=3","gravatar_id":"","url":"https://api.github.com/users/hunchback","html_url":"https://github.com/hunchback","followers_url":"https://api.github.com/users/hunchback/followers","following_url":"https://api.github.com/users/hunchback/following{/other_user}","gists_url":"https://api.github.com/users/hunchback/gists{/gist_id}","starred_url":"https://api.github.com/users/hunchback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunchback/subscriptions","organizations_url":"https://api.github.com/users/hunchback/orgs","repos_url":"https://api.github.com/users/hunchback/repos","events_url":"https://api.github.com/users/hunchback/events{/privacy}","received_events_url":"https://api.github.com/users/hunchback/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hunchback/ob1k","description":"Ob1k - The RPC Framework","fork":true,"url":"https://api.github.com/repos/hunchback/ob1k","forks_url":"https://api.github.com/repos/hunchback/ob1k/forks","keys_url":"https://api.github.com/repos/hunchback/ob1k/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hunchback/ob1k/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hunchback/ob1k/teams","hooks_url":"https://api.github.com/repos/hunchback/ob1k/hooks","issue_events_url":"https://api.github.com/repos/hunchback/ob1k/issues/events{/number}","events_url":"https://api.github.com/repos/hunchback/ob1k/events","assignees_url":"https://api.github.com/repos/hunchback/ob1k/assignees{/user}","branches_url":"https://api.github.com/repos/hunchback/ob1k/branches{/branch}","tags_url":"https://api.github.com/repos/hunchback/ob1k/tags","blobs_url":"https://api.github.com/repos/hunchback/ob1k/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hunchback/ob1k/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hunchback/ob1k/git/refs{/sha}","trees_url":"https://api.github.com/repos/hunchback/ob1k/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hunchback/ob1k/statuses/{sha}","languages_url":"https://api.github.com/repos/hunchback/ob1k/languages","stargazers_url":"https://api.github.com/repos/hunchback/ob1k/stargazers","contributors_url":"https://api.github.com/repos/hunchback/ob1k/contributors","subscribers_url":"https://api.github.com/repos/hunchback/ob1k/subscribers","subscription_url":"https://api.github.com/repos/hunchback/ob1k/subscription","commits_url":"https://api.github.com/repos/hunchback/ob1k/commits{/sha}","git_commits_url":"https://api.github.com/repos/hunchback/ob1k/git/commits{/sha}","comments_url":"https://api.github.com/repos/hunchback/ob1k/comments{/number}","issue_comment_url":"https://api.github.com/repos/hunchback/ob1k/issues/comments{/number}","contents_url":"https://api.github.com/repos/hunchback/ob1k/contents/{+path}","compare_url":"https://api.github.com/repos/hunchback/ob1k/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hunchback/ob1k/merges","archive_url":"https://api.github.com/repos/hunchback/ob1k/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hunchback/ob1k/downloads","issues_url":"https://api.github.com/repos/hunchback/ob1k/issues{/number}","pulls_url":"https://api.github.com/repos/hunchback/ob1k/pulls{/number}","milestones_url":"https://api.github.com/repos/hunchback/ob1k/milestones{/number}","notifications_url":"https://api.github.com/repos/hunchback/ob1k/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hunchback/ob1k/labels{/name}","releases_url":"https://api.github.com/repos/hunchback/ob1k/releases{/id}","created_at":"2015-11-24T15:19:53Z","updated_at":"2015-11-24T15:19:55Z","pushed_at":"2015-12-18T10:45:11Z","git_url":"git://github.com/hunchback/ob1k.git","ssh_url":"git@github.com:hunchback/ob1k.git","clone_url":"https://github.com/hunchback/ob1k.git","svn_url":"https://github.com/hunchback/ob1k","homepage":null,"size":1539,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"outbrain:master","ref":"master","sha":"56531170edb8751c2fab2fb74ca4dc32dccf3cb3","user":{"login":"outbrain","id":1535932,"avatar_url":"https://avatars.githubusercontent.com/u/1535932?v=3","gravatar_id":"","url":"https://api.github.com/users/outbrain","html_url":"https://github.com/outbrain","followers_url":"https://api.github.com/users/outbrain/followers","following_url":"https://api.github.com/users/outbrain/following{/other_user}","gists_url":"https://api.github.com/users/outbrain/gists{/gist_id}","starred_url":"https://api.github.com/users/outbrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/outbrain/subscriptions","organizations_url":"https://api.github.com/users/outbrain/orgs","repos_url":"https://api.github.com/users/outbrain/repos","events_url":"https://api.github.com/users/outbrain/events{/privacy}","received_events_url":"https://api.github.com/users/outbrain/received_events","type":"Organization","site_admin":false},"repo":{"id":25582637,"name":"ob1k","full_name":"outbrain/ob1k","owner":{"login":"outbrain","id":1535932,"avatar_url":"https://avatars.githubusercontent.com/u/1535932?v=3","gravatar_id":"","url":"https://api.github.com/users/outbrain","html_url":"https://github.com/outbrain","followers_url":"https://api.github.com/users/outbrain/followers","following_url":"https://api.github.com/users/outbrain/following{/other_user}","gists_url":"https://api.github.com/users/outbrain/gists{/gist_id}","starred_url":"https://api.github.com/users/outbrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/outbrain/subscriptions","organizations_url":"https://api.github.com/users/outbrain/orgs","repos_url":"https://api.github.com/users/outbrain/repos","events_url":"https://api.github.com/users/outbrain/events{/privacy}","received_events_url":"https://api.github.com/users/outbrain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/outbrain/ob1k","description":"Ob1k - The RPC Framework","fork":false,"url":"https://api.github.com/repos/outbrain/ob1k","forks_url":"https://api.github.com/repos/outbrain/ob1k/forks","keys_url":"https://api.github.com/repos/outbrain/ob1k/keys{/key_id}","collaborators_url":"https://api.github.com/repos/outbrain/ob1k/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/outbrain/ob1k/teams","hooks_url":"https://api.github.com/repos/outbrain/ob1k/hooks","issue_events_url":"https://api.github.com/repos/outbrain/ob1k/issues/events{/number}","events_url":"https://api.github.com/repos/outbrain/ob1k/events","assignees_url":"https://api.github.com/repos/outbrain/ob1k/assignees{/user}","branches_url":"https://api.github.com/repos/outbrain/ob1k/branches{/branch}","tags_url":"https://api.github.com/repos/outbrain/ob1k/tags","blobs_url":"https://api.github.com/repos/outbrain/ob1k/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/outbrain/ob1k/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/outbrain/ob1k/git/refs{/sha}","trees_url":"https://api.github.com/repos/outbrain/ob1k/git/trees{/sha}","statuses_url":"https://api.github.com/repos/outbrain/ob1k/statuses/{sha}","languages_url":"https://api.github.com/repos/outbrain/ob1k/languages","stargazers_url":"https://api.github.com/repos/outbrain/ob1k/stargazers","contributors_url":"https://api.github.com/repos/outbrain/ob1k/contributors","subscribers_url":"https://api.github.com/repos/outbrain/ob1k/subscribers","subscription_url":"https://api.github.com/repos/outbrain/ob1k/subscription","commits_url":"https://api.github.com/repos/outbrain/ob1k/commits{/sha}","git_commits_url":"https://api.github.com/repos/outbrain/ob1k/git/commits{/sha}","comments_url":"https://api.github.com/repos/outbrain/ob1k/comments{/number}","issue_comment_url":"https://api.github.com/repos/outbrain/ob1k/issues/comments{/number}","contents_url":"https://api.github.com/repos/outbrain/ob1k/contents/{+path}","compare_url":"https://api.github.com/repos/outbrain/ob1k/compare/{base}...{head}","merges_url":"https://api.github.com/repos/outbrain/ob1k/merges","archive_url":"https://api.github.com/repos/outbrain/ob1k/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/outbrain/ob1k/downloads","issues_url":"https://api.github.com/repos/outbrain/ob1k/issues{/number}","pulls_url":"https://api.github.com/repos/outbrain/ob1k/pulls{/number}","milestones_url":"https://api.github.com/repos/outbrain/ob1k/milestones{/number}","notifications_url":"https://api.github.com/repos/outbrain/ob1k/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/outbrain/ob1k/labels{/name}","releases_url":"https://api.github.com/repos/outbrain/ob1k/releases{/id}","created_at":"2014-10-22T13:24:51Z","updated_at":"2015-12-14T16:57:17Z","pushed_at":"2015-12-22T15:58:51Z","git_url":"git://github.com/outbrain/ob1k.git","ssh_url":"git@github.com:outbrain/ob1k.git","clone_url":"https://github.com/outbrain/ob1k.git","svn_url":"https://github.com/outbrain/ob1k","homepage":null,"size":1590,"stargazers_count":17,"watchers_count":17,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8,"mirror_url":null,"open_issues_count":2,"forks":8,"open_issues":2,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/outbrain/ob1k/pulls/29"},"html":{"href":"https://github.com/outbrain/ob1k/pull/29"},"issue":{"href":"https://api.github.com/repos/outbrain/ob1k/issues/29"},"comments":{"href":"https://api.github.com/repos/outbrain/ob1k/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/outbrain/ob1k/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/outbrain/ob1k/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/outbrain/ob1k/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/outbrain/ob1k/statuses/721457dca373bc6f0efd49054fa6e4814ab4fdac"}}}}