{"action":"created","comment":{"url":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/comments/135699146","pull_request_review_id":59137381,"id":135699146,"diff_hunk":"@@ -0,0 +1,115 @@\n+/*\n+ Copyright 2013 Red Hat, Inc. and/or its affiliates.\n+\n+ This file is part of lightblue.\n+\n+ This program is free software: you can redistribute it and/or modify\n+ it under the terms of the GNU General Public License as published by\n+ the Free Software Foundation, either version 3 of the License, or\n+ (at your option) any later version.\n+\n+ This program is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ GNU General Public License for more details.\n+\n+ You should have received a copy of the GNU General Public License\n+ along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+package com.redhat.lightblue.util.metrics;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import org.junit.Assert;\n+import org.junit.Test;\n+\n+import com.codahale.metrics.Counter;\n+import com.codahale.metrics.Meter;\n+import com.codahale.metrics.MetricRegistry;\n+import com.codahale.metrics.Timer;\n+import com.redhat.lightblue.util.Error;\n+\n+public class DropwizardRequestMetricsTest {\n+    // Use fresh registry for each test\n+    private MetricRegistry metricsRegistry = new MetricRegistry();\n+    private RequestMetrics requestMetrics = new DropwizardRequestMetrics(metricsRegistry);\n+\n+    @Test\n+    public void testStartRequestMonitoring() {\n+        requestMetrics.startEntityRequest(\"bulk\", null, null);\n+        Assert.assertNotNull(metricsRegistry.getCounters());\n+        Assert.assertNotNull(metricsRegistry.getTimers());\n+\n+        Counter activeRequestCounter = metricsRegistry.counter(\"api.bulk.requests.active\");\n+        Timer completedRequestTimer = metricsRegistry.timer(\"api.bulk.requests.completed\");\n+\n+        Assert.assertEquals(1, activeRequestCounter.getCount());\n+        Assert.assertEquals(0, completedRequestTimer.getCount());\n+        Assert.assertNotNull(completedRequestTimer.getMeanRate());\n+    }\n+\n+    @Test\n+    public void testEndRequestMonitoring() {\n+        DropwizardRequestMetrics.Context context = requestMetrics.startEntityRequest(\"explain\", \"name\", \"version\");\n+        context.endRequestMonitoring();\n+\n+        Counter activeRequestCounter = metricsRegistry.counter(\"api.explain.name.version.requests.active\");\n+        Timer completedRequestTimer = metricsRegistry.timer(\"api.explain.name.version.requests.latency\");\n+\n+        Assert.assertEquals(0, activeRequestCounter.getCount());\n+        Assert.assertEquals(1, completedRequestTimer.getCount());\n+        Assert.assertNotNull(completedRequestTimer.getOneMinuteRate());\n+    }\n+\n+    @Test\n+    public void testMarkRequestExceptionWithError() {\n+        DropwizardRequestMetrics.Context context = requestMetrics.startStreamingEntityRequest(\"find\", \"name\", \"version\");\n+        context.markRequestException(Error.get(\"errorCode\"));\n+        \n+        Meter exceptionMeter = metricsRegistry.meter(\"api.stream.find.name.version.requests.exception.Error.errorCode\");\n+        Assert.assertEquals(1, exceptionMeter.getCount());\n+    }\n+\n+    @Test\n+    public void testMarkRequestExceptionWithException() {\n+        DropwizardRequestMetrics.Context context = requestMetrics.startBulkRequest();\n+        context.markRequestException(new Exception(\"bulk request exception\"));\n+        Meter exceptionMeter = metricsRegistry.meter(\"api.bulk.requests.exception.Exception.bulk.request.exception\");\n+        Assert.assertEquals(1, exceptionMeter.getCount());\n+    }\n+    \n+    @Test\n+    public void testMarkRequestExceptionWithRegex() {\n+        DropwizardRequestMetrics.Context context = requestMetrics.startLockRequest(\"lockcommand\", \"domain\");\n+        context.markRequestException(new NullPointerException(\"this@tests$the_regex#pattern\"));\n+        Meter exceptionMeter = metricsRegistry.meter(\"api.lock.domain.lockcommand.requests.exception.NullPointerException.this.tests.the.regex.pattern\");","path":"util/src/test/java/com/redhat/lightblue/util/metrics/DropwizardRequestMetricsTest.java","position":null,"original_position":86,"commit_id":"db2dfc515cfeb31b1d1d37150cb385be09bdc154","original_commit_id":"0cdf4c7aa4ed4096e603b3501bf5f2bfa618ea30","user":{"login":"svkm102","id":9564516,"avatar_url":"https://avatars0.githubusercontent.com/u/9564516?v=4","gravatar_id":"","url":"https://api.github.com/users/svkm102","html_url":"https://github.com/svkm102","followers_url":"https://api.github.com/users/svkm102/followers","following_url":"https://api.github.com/users/svkm102/following{/other_user}","gists_url":"https://api.github.com/users/svkm102/gists{/gist_id}","starred_url":"https://api.github.com/users/svkm102/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svkm102/subscriptions","organizations_url":"https://api.github.com/users/svkm102/orgs","repos_url":"https://api.github.com/users/svkm102/repos","events_url":"https://api.github.com/users/svkm102/events{/privacy}","received_events_url":"https://api.github.com/users/svkm102/received_events","type":"User","site_admin":false},"body":"Updated test cases and included some new tests for better coverage.","created_at":"2017-08-29T05:51:03Z","updated_at":"2017-08-29T05:51:03Z","html_url":"https://github.com/lightblue-platform/lightblue-core/pull/808#discussion_r135699146","pull_request_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/808","_links":{"self":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/comments/135699146"},"html":{"href":"https://github.com/lightblue-platform/lightblue-core/pull/808#discussion_r135699146"},"pull_request":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/808"}},"in_reply_to_id":135603336},"pull_request":{"url":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/808","id":135118306,"html_url":"https://github.com/lightblue-platform/lightblue-core/pull/808","diff_url":"https://github.com/lightblue-platform/lightblue-core/pull/808.diff","patch_url":"https://github.com/lightblue-platform/lightblue-core/pull/808.patch","issue_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/issues/808","number":808,"state":"open","locked":false,"title":"Move metrics in lbcore","user":{"login":"svkm102","id":9564516,"avatar_url":"https://avatars0.githubusercontent.com/u/9564516?v=4","gravatar_id":"","url":"https://api.github.com/users/svkm102","html_url":"https://github.com/svkm102","followers_url":"https://api.github.com/users/svkm102/followers","following_url":"https://api.github.com/users/svkm102/following{/other_user}","gists_url":"https://api.github.com/users/svkm102/gists{/gist_id}","starred_url":"https://api.github.com/users/svkm102/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svkm102/subscriptions","organizations_url":"https://api.github.com/users/svkm102/orgs","repos_url":"https://api.github.com/users/svkm102/repos","events_url":"https://api.github.com/users/svkm102/events{/privacy}","received_events_url":"https://api.github.com/users/svkm102/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-10T13:00:10Z","updated_at":"2017-08-29T05:51:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"092fc73efa6897d5f3c2eb6fa87e14d78fc0cecd","assignee":null,"assignees":[],"requested_reviewers":[{"login":"derek63","id":990017,"avatar_url":"https://avatars3.githubusercontent.com/u/990017?v=4","gravatar_id":"","url":"https://api.github.com/users/derek63","html_url":"https://github.com/derek63","followers_url":"https://api.github.com/users/derek63/followers","following_url":"https://api.github.com/users/derek63/following{/other_user}","gists_url":"https://api.github.com/users/derek63/gists{/gist_id}","starred_url":"https://api.github.com/users/derek63/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derek63/subscriptions","organizations_url":"https://api.github.com/users/derek63/orgs","repos_url":"https://api.github.com/users/derek63/repos","events_url":"https://api.github.com/users/derek63/events{/privacy}","received_events_url":"https://api.github.com/users/derek63/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/808/commits","review_comments_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/808/comments","review_comment_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/issues/808/comments","statuses_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/statuses/db2dfc515cfeb31b1d1d37150cb385be09bdc154","head":{"label":"svkm102:metrics","ref":"metrics","sha":"db2dfc515cfeb31b1d1d37150cb385be09bdc154","user":{"login":"svkm102","id":9564516,"avatar_url":"https://avatars0.githubusercontent.com/u/9564516?v=4","gravatar_id":"","url":"https://api.github.com/users/svkm102","html_url":"https://github.com/svkm102","followers_url":"https://api.github.com/users/svkm102/followers","following_url":"https://api.github.com/users/svkm102/following{/other_user}","gists_url":"https://api.github.com/users/svkm102/gists{/gist_id}","starred_url":"https://api.github.com/users/svkm102/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svkm102/subscriptions","organizations_url":"https://api.github.com/users/svkm102/orgs","repos_url":"https://api.github.com/users/svkm102/repos","events_url":"https://api.github.com/users/svkm102/events{/privacy}","received_events_url":"https://api.github.com/users/svkm102/received_events","type":"User","site_admin":false},"repo":{"id":96506627,"name":"lightblue-core","full_name":"svkm102/lightblue-core","owner":{"login":"svkm102","id":9564516,"avatar_url":"https://avatars0.githubusercontent.com/u/9564516?v=4","gravatar_id":"","url":"https://api.github.com/users/svkm102","html_url":"https://github.com/svkm102","followers_url":"https://api.github.com/users/svkm102/followers","following_url":"https://api.github.com/users/svkm102/following{/other_user}","gists_url":"https://api.github.com/users/svkm102/gists{/gist_id}","starred_url":"https://api.github.com/users/svkm102/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svkm102/subscriptions","organizations_url":"https://api.github.com/users/svkm102/orgs","repos_url":"https://api.github.com/users/svkm102/repos","events_url":"https://api.github.com/users/svkm102/events{/privacy}","received_events_url":"https://api.github.com/users/svkm102/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/svkm102/lightblue-core","description":"Document based data access layer framework","fork":true,"url":"https://api.github.com/repos/svkm102/lightblue-core","forks_url":"https://api.github.com/repos/svkm102/lightblue-core/forks","keys_url":"https://api.github.com/repos/svkm102/lightblue-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/svkm102/lightblue-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/svkm102/lightblue-core/teams","hooks_url":"https://api.github.com/repos/svkm102/lightblue-core/hooks","issue_events_url":"https://api.github.com/repos/svkm102/lightblue-core/issues/events{/number}","events_url":"https://api.github.com/repos/svkm102/lightblue-core/events","assignees_url":"https://api.github.com/repos/svkm102/lightblue-core/assignees{/user}","branches_url":"https://api.github.com/repos/svkm102/lightblue-core/branches{/branch}","tags_url":"https://api.github.com/repos/svkm102/lightblue-core/tags","blobs_url":"https://api.github.com/repos/svkm102/lightblue-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/svkm102/lightblue-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/svkm102/lightblue-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/svkm102/lightblue-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/svkm102/lightblue-core/statuses/{sha}","languages_url":"https://api.github.com/repos/svkm102/lightblue-core/languages","stargazers_url":"https://api.github.com/repos/svkm102/lightblue-core/stargazers","contributors_url":"https://api.github.com/repos/svkm102/lightblue-core/contributors","subscribers_url":"https://api.github.com/repos/svkm102/lightblue-core/subscribers","subscription_url":"https://api.github.com/repos/svkm102/lightblue-core/subscription","commits_url":"https://api.github.com/repos/svkm102/lightblue-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/svkm102/lightblue-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/svkm102/lightblue-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/svkm102/lightblue-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/svkm102/lightblue-core/contents/{+path}","compare_url":"https://api.github.com/repos/svkm102/lightblue-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/svkm102/lightblue-core/merges","archive_url":"https://api.github.com/repos/svkm102/lightblue-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/svkm102/lightblue-core/downloads","issues_url":"https://api.github.com/repos/svkm102/lightblue-core/issues{/number}","pulls_url":"https://api.github.com/repos/svkm102/lightblue-core/pulls{/number}","milestones_url":"https://api.github.com/repos/svkm102/lightblue-core/milestones{/number}","notifications_url":"https://api.github.com/repos/svkm102/lightblue-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/svkm102/lightblue-core/labels{/name}","releases_url":"https://api.github.com/repos/svkm102/lightblue-core/releases{/id}","deployments_url":"https://api.github.com/repos/svkm102/lightblue-core/deployments","created_at":"2017-07-07T06:30:21Z","updated_at":"2017-07-07T06:30:24Z","pushed_at":"2017-08-29T05:48:22Z","git_url":"git://github.com/svkm102/lightblue-core.git","ssh_url":"git@github.com:svkm102/lightblue-core.git","clone_url":"https://github.com/svkm102/lightblue-core.git","svn_url":"https://github.com/svkm102/lightblue-core","homepage":"","size":9399,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"lightblue-platform:master","ref":"master","sha":"fb7c72db9e7f51d951a752133c9cfba22a9fd519","user":{"login":"lightblue-platform","id":7061725,"avatar_url":"https://avatars1.githubusercontent.com/u/7061725?v=4","gravatar_id":"","url":"https://api.github.com/users/lightblue-platform","html_url":"https://github.com/lightblue-platform","followers_url":"https://api.github.com/users/lightblue-platform/followers","following_url":"https://api.github.com/users/lightblue-platform/following{/other_user}","gists_url":"https://api.github.com/users/lightblue-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/lightblue-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightblue-platform/subscriptions","organizations_url":"https://api.github.com/users/lightblue-platform/orgs","repos_url":"https://api.github.com/users/lightblue-platform/repos","events_url":"https://api.github.com/users/lightblue-platform/events{/privacy}","received_events_url":"https://api.github.com/users/lightblue-platform/received_events","type":"Organization","site_admin":false},"repo":{"id":14145700,"name":"lightblue-core","full_name":"lightblue-platform/lightblue-core","owner":{"login":"lightblue-platform","id":7061725,"avatar_url":"https://avatars1.githubusercontent.com/u/7061725?v=4","gravatar_id":"","url":"https://api.github.com/users/lightblue-platform","html_url":"https://github.com/lightblue-platform","followers_url":"https://api.github.com/users/lightblue-platform/followers","following_url":"https://api.github.com/users/lightblue-platform/following{/other_user}","gists_url":"https://api.github.com/users/lightblue-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/lightblue-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightblue-platform/subscriptions","organizations_url":"https://api.github.com/users/lightblue-platform/orgs","repos_url":"https://api.github.com/users/lightblue-platform/repos","events_url":"https://api.github.com/users/lightblue-platform/events{/privacy}","received_events_url":"https://api.github.com/users/lightblue-platform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lightblue-platform/lightblue-core","description":"Document based data access layer framework","fork":false,"url":"https://api.github.com/repos/lightblue-platform/lightblue-core","forks_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/forks","keys_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/teams","hooks_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/hooks","issue_events_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/issues/events{/number}","events_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/events","assignees_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/assignees{/user}","branches_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/branches{/branch}","tags_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/tags","blobs_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/statuses/{sha}","languages_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/languages","stargazers_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/stargazers","contributors_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/contributors","subscribers_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/subscribers","subscription_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/subscription","commits_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/contents/{+path}","compare_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/merges","archive_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/downloads","issues_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/issues{/number}","pulls_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls{/number}","milestones_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/milestones{/number}","notifications_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/labels{/name}","releases_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/releases{/id}","deployments_url":"https://api.github.com/repos/lightblue-platform/lightblue-core/deployments","created_at":"2013-11-05T15:44:42Z","updated_at":"2017-08-14T19:01:09Z","pushed_at":"2017-08-29T05:48:23Z","git_url":"git://github.com/lightblue-platform/lightblue-core.git","ssh_url":"git@github.com:lightblue-platform/lightblue-core.git","clone_url":"https://github.com/lightblue-platform/lightblue-core.git","svn_url":"https://github.com/lightblue-platform/lightblue-core","homepage":"","size":9343,"stargazers_count":27,"watchers_count":27,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":126,"forks":22,"open_issues":126,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/808"},"html":{"href":"https://github.com/lightblue-platform/lightblue-core/pull/808"},"issue":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-core/issues/808"},"comments":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-core/issues/808/comments"},"review_comments":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/808/comments"},"review_comment":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-core/pulls/808/commits"},"statuses":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-core/statuses/db2dfc515cfeb31b1d1d37150cb385be09bdc154"}}}}
{"actor":{"display_login":"svkm102"}}