{"action":"created","comment":{"url":"https://api.github.com/repos/apache/samza/pulls/comments/180557380","pull_request_review_id":110998703,"id":180557380,"diff_hunk":"@@ -1,62 +1,81 @@\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+ * 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.samza.system.eventhub.metrics;\n \n import com.codahale.metrics.ExponentiallyDecayingReservoir;\n import com.codahale.metrics.Histogram;\n import com.codahale.metrics.Snapshot;\n-import org.apache.samza.metrics.Gauge;\n-import org.apache.samza.metrics.MetricsRegistry;\n-\n import java.util.Arrays;\n import java.util.List;\n import java.util.Map;\n+import java.util.concurrent.ScheduledExecutorService;\n+import java.util.concurrent.TimeUnit;\n import java.util.function.Function;\n import java.util.stream.Collectors;\n+import org.apache.samza.metrics.Gauge;\n+import org.apache.samza.metrics.MetricsRegistry;\n+import org.apache.samza.system.eventhub.SamzaEventHubClientManager;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n \n /**\n  * Creates a {@link Histogram} metric using {@link ExponentiallyDecayingReservoir}\n  * Keeps a {@link Gauge} for each percentile\n  */\n-public class SamzaHistogram {\n+public class SamzaHistogram implements Runnable {\n+  private static final Logger LOG = LoggerFactory.getLogger(SamzaEventHubClientManager.class.getName());\n   private static final List<Double> DEFAULT_HISTOGRAM_PERCENTILES = Arrays.asList(50D, 99D);\n+  private static final int UPDATE_FREQUENCY_MS = 60000; // 1 minute\n   private final Histogram histogram;\n   private final List<Double> percentiles;\n   private final Map<Double, Gauge<Double>> gauges;\n+  private final String name;\n \n-  public SamzaHistogram(MetricsRegistry registry, String group, String name) {\n-    this(registry, group, name, DEFAULT_HISTOGRAM_PERCENTILES);\n+  public SamzaHistogram(MetricsRegistry registry, String group, String name, ScheduledExecutorService executorService) {\n+    this(registry, group, name, DEFAULT_HISTOGRAM_PERCENTILES, executorService);\n   }\n \n-  public SamzaHistogram(MetricsRegistry registry, String group, String name, List<Double> percentiles) {\n+  public SamzaHistogram(MetricsRegistry registry, String group, String name, List<Double> percentiles,\n+      ScheduledExecutorService executorService) {\n+    this.name = name;\n     this.histogram = new Histogram(new ExponentiallyDecayingReservoir());\n     this.percentiles = percentiles;\n     this.gauges = this.percentiles.stream()\n-            .filter(x -> x > 0 && x <= 100)\n-            .collect(\n-                    Collectors.toMap(Function.identity(), x -> registry.newGauge(group, name + \"_\" + String.valueOf(0), 0D)));\n+        .filter(x -> x > 0 && x <= 100)\n+        .collect(\n+            Collectors.toMap(Function.identity(), x -> registry.newGauge(group, name + \"_\" + String.valueOf(0), 0D)));\n+    executorService.schedule(this, UPDATE_FREQUENCY_MS, TimeUnit.MILLISECONDS);","path":"samza-azure/src/main/java/org/apache/samza/system/eventhub/metrics/SamzaHistogram.java","position":92,"original_position":92,"commit_id":"634ab8d99b2282e785e3758602a0dcb01289b2c9","original_commit_id":"cadbd81d763e171daf00742edbfc38ef097c32db","user":{"login":"srinipunuru","id":1783806,"avatar_url":"https://avatars2.githubusercontent.com/u/1783806?v=4","gravatar_id":"","url":"https://api.github.com/users/srinipunuru","html_url":"https://github.com/srinipunuru","followers_url":"https://api.github.com/users/srinipunuru/followers","following_url":"https://api.github.com/users/srinipunuru/following{/other_user}","gists_url":"https://api.github.com/users/srinipunuru/gists{/gist_id}","starred_url":"https://api.github.com/users/srinipunuru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srinipunuru/subscriptions","organizations_url":"https://api.github.com/users/srinipunuru/orgs","repos_url":"https://api.github.com/users/srinipunuru/repos","events_url":"https://api.github.com/users/srinipunuru/events{/privacy}","received_events_url":"https://api.github.com/users/srinipunuru/received_events","type":"User","site_admin":false},"body":"Good catch!","created_at":"2018-04-10T20:29:19Z","updated_at":"2018-04-10T20:29:19Z","html_url":"https://github.com/apache/samza/pull/467#discussion_r180557380","pull_request_url":"https://api.github.com/repos/apache/samza/pulls/467","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/samza/pulls/comments/180557380"},"html":{"href":"https://github.com/apache/samza/pull/467#discussion_r180557380"},"pull_request":{"href":"https://api.github.com/repos/apache/samza/pulls/467"}},"in_reply_to_id":180556243},"pull_request":{"url":"https://api.github.com/repos/apache/samza/pulls/467","id":180663468,"html_url":"https://github.com/apache/samza/pull/467","diff_url":"https://github.com/apache/samza/pull/467.diff","patch_url":"https://github.com/apache/samza/pull/467.patch","issue_url":"https://api.github.com/repos/apache/samza/issues/467","number":467,"state":"open","locked":false,"title":"Upgrade to latest event hub version (1.0.1)","user":{"login":"srinipunuru","id":1783806,"avatar_url":"https://avatars2.githubusercontent.com/u/1783806?v=4","gravatar_id":"","url":"https://api.github.com/users/srinipunuru","html_url":"https://github.com/srinipunuru","followers_url":"https://api.github.com/users/srinipunuru/followers","following_url":"https://api.github.com/users/srinipunuru/following{/other_user}","gists_url":"https://api.github.com/users/srinipunuru/gists{/gist_id}","starred_url":"https://api.github.com/users/srinipunuru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srinipunuru/subscriptions","organizations_url":"https://api.github.com/users/srinipunuru/orgs","repos_url":"https://api.github.com/users/srinipunuru/repos","events_url":"https://api.github.com/users/srinipunuru/events{/privacy}","received_events_url":"https://api.github.com/users/srinipunuru/received_events","type":"User","site_admin":false},"body":"* Upgrade to the latest event hub version 1.0.1\r\n* Adding configs for prefetchCount and maxEventPerPoll\r\n* Fix the high cpu usage issue in SamzaHistogram\r\n* Fixing a race condition in event hub system producer where the future was getting removed while it was being checked for completion resulting in NPE.","created_at":"2018-04-10T16:43:41Z","updated_at":"2018-04-10T20:29:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c5c0e6df00406455c31ca9b95853a62f3f1935e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/samza/pulls/467/commits","review_comments_url":"https://api.github.com/repos/apache/samza/pulls/467/comments","review_comment_url":"https://api.github.com/repos/apache/samza/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/samza/issues/467/comments","statuses_url":"https://api.github.com/repos/apache/samza/statuses/634ab8d99b2282e785e3758602a0dcb01289b2c9","head":{"label":"srinipunuru:upgrade-eh-1.0.1","ref":"upgrade-eh-1.0.1","sha":"634ab8d99b2282e785e3758602a0dcb01289b2c9","user":{"login":"srinipunuru","id":1783806,"avatar_url":"https://avatars2.githubusercontent.com/u/1783806?v=4","gravatar_id":"","url":"https://api.github.com/users/srinipunuru","html_url":"https://github.com/srinipunuru","followers_url":"https://api.github.com/users/srinipunuru/followers","following_url":"https://api.github.com/users/srinipunuru/following{/other_user}","gists_url":"https://api.github.com/users/srinipunuru/gists{/gist_id}","starred_url":"https://api.github.com/users/srinipunuru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srinipunuru/subscriptions","organizations_url":"https://api.github.com/users/srinipunuru/orgs","repos_url":"https://api.github.com/users/srinipunuru/repos","events_url":"https://api.github.com/users/srinipunuru/events{/privacy}","received_events_url":"https://api.github.com/users/srinipunuru/received_events","type":"User","site_admin":false},"repo":{"id":103319468,"name":"samza","full_name":"srinipunuru/samza","owner":{"login":"srinipunuru","id":1783806,"avatar_url":"https://avatars2.githubusercontent.com/u/1783806?v=4","gravatar_id":"","url":"https://api.github.com/users/srinipunuru","html_url":"https://github.com/srinipunuru","followers_url":"https://api.github.com/users/srinipunuru/followers","following_url":"https://api.github.com/users/srinipunuru/following{/other_user}","gists_url":"https://api.github.com/users/srinipunuru/gists{/gist_id}","starred_url":"https://api.github.com/users/srinipunuru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srinipunuru/subscriptions","organizations_url":"https://api.github.com/users/srinipunuru/orgs","repos_url":"https://api.github.com/users/srinipunuru/repos","events_url":"https://api.github.com/users/srinipunuru/events{/privacy}","received_events_url":"https://api.github.com/users/srinipunuru/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/srinipunuru/samza","description":"Mirror of Apache Samza","fork":true,"url":"https://api.github.com/repos/srinipunuru/samza","forks_url":"https://api.github.com/repos/srinipunuru/samza/forks","keys_url":"https://api.github.com/repos/srinipunuru/samza/keys{/key_id}","collaborators_url":"https://api.github.com/repos/srinipunuru/samza/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/srinipunuru/samza/teams","hooks_url":"https://api.github.com/repos/srinipunuru/samza/hooks","issue_events_url":"https://api.github.com/repos/srinipunuru/samza/issues/events{/number}","events_url":"https://api.github.com/repos/srinipunuru/samza/events","assignees_url":"https://api.github.com/repos/srinipunuru/samza/assignees{/user}","branches_url":"https://api.github.com/repos/srinipunuru/samza/branches{/branch}","tags_url":"https://api.github.com/repos/srinipunuru/samza/tags","blobs_url":"https://api.github.com/repos/srinipunuru/samza/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/srinipunuru/samza/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/srinipunuru/samza/git/refs{/sha}","trees_url":"https://api.github.com/repos/srinipunuru/samza/git/trees{/sha}","statuses_url":"https://api.github.com/repos/srinipunuru/samza/statuses/{sha}","languages_url":"https://api.github.com/repos/srinipunuru/samza/languages","stargazers_url":"https://api.github.com/repos/srinipunuru/samza/stargazers","contributors_url":"https://api.github.com/repos/srinipunuru/samza/contributors","subscribers_url":"https://api.github.com/repos/srinipunuru/samza/subscribers","subscription_url":"https://api.github.com/repos/srinipunuru/samza/subscription","commits_url":"https://api.github.com/repos/srinipunuru/samza/commits{/sha}","git_commits_url":"https://api.github.com/repos/srinipunuru/samza/git/commits{/sha}","comments_url":"https://api.github.com/repos/srinipunuru/samza/comments{/number}","issue_comment_url":"https://api.github.com/repos/srinipunuru/samza/issues/comments{/number}","contents_url":"https://api.github.com/repos/srinipunuru/samza/contents/{+path}","compare_url":"https://api.github.com/repos/srinipunuru/samza/compare/{base}...{head}","merges_url":"https://api.github.com/repos/srinipunuru/samza/merges","archive_url":"https://api.github.com/repos/srinipunuru/samza/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/srinipunuru/samza/downloads","issues_url":"https://api.github.com/repos/srinipunuru/samza/issues{/number}","pulls_url":"https://api.github.com/repos/srinipunuru/samza/pulls{/number}","milestones_url":"https://api.github.com/repos/srinipunuru/samza/milestones{/number}","notifications_url":"https://api.github.com/repos/srinipunuru/samza/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/srinipunuru/samza/labels{/name}","releases_url":"https://api.github.com/repos/srinipunuru/samza/releases{/id}","deployments_url":"https://api.github.com/repos/srinipunuru/samza/deployments","created_at":"2017-09-12T20:52:41Z","updated_at":"2018-03-27T16:10:06Z","pushed_at":"2018-04-10T20:20:17Z","git_url":"git://github.com/srinipunuru/samza.git","ssh_url":"git@github.com:srinipunuru/samza.git","clone_url":"https://github.com/srinipunuru/samza.git","svn_url":"https://github.com/srinipunuru/samza","homepage":null,"size":19861,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"8e000f3984e6158b504bc9cad0c81ea3d260cea3","user":{"login":"apache","id":47359,"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":32199982,"name":"samza","full_name":"apache/samza","owner":{"login":"apache","id":47359,"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},"private":false,"html_url":"https://github.com/apache/samza","description":"Mirror of Apache Samza","fork":false,"url":"https://api.github.com/repos/apache/samza","forks_url":"https://api.github.com/repos/apache/samza/forks","keys_url":"https://api.github.com/repos/apache/samza/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/samza/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/samza/teams","hooks_url":"https://api.github.com/repos/apache/samza/hooks","issue_events_url":"https://api.github.com/repos/apache/samza/issues/events{/number}","events_url":"https://api.github.com/repos/apache/samza/events","assignees_url":"https://api.github.com/repos/apache/samza/assignees{/user}","branches_url":"https://api.github.com/repos/apache/samza/branches{/branch}","tags_url":"https://api.github.com/repos/apache/samza/tags","blobs_url":"https://api.github.com/repos/apache/samza/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/samza/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/samza/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/samza/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/samza/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/samza/languages","stargazers_url":"https://api.github.com/repos/apache/samza/stargazers","contributors_url":"https://api.github.com/repos/apache/samza/contributors","subscribers_url":"https://api.github.com/repos/apache/samza/subscribers","subscription_url":"https://api.github.com/repos/apache/samza/subscription","commits_url":"https://api.github.com/repos/apache/samza/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/samza/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/samza/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/samza/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/samza/contents/{+path}","compare_url":"https://api.github.com/repos/apache/samza/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/samza/merges","archive_url":"https://api.github.com/repos/apache/samza/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/samza/downloads","issues_url":"https://api.github.com/repos/apache/samza/issues{/number}","pulls_url":"https://api.github.com/repos/apache/samza/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/samza/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/samza/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/samza/labels{/name}","releases_url":"https://api.github.com/repos/apache/samza/releases{/id}","deployments_url":"https://api.github.com/repos/apache/samza/deployments","created_at":"2015-03-14T07:00:05Z","updated_at":"2018-04-09T09:11:05Z","pushed_at":"2018-04-10T20:20:18Z","git_url":"git://github.com/apache/samza.git","ssh_url":"git@github.com:apache/samza.git","clone_url":"https://github.com/apache/samza.git","svn_url":"https://github.com/apache/samza","homepage":null,"size":19349,"stargazers_count":416,"watchers_count":416,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":182,"mirror_url":null,"archived":false,"open_issues_count":22,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":182,"open_issues":22,"watchers":416,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/samza/pulls/467"},"html":{"href":"https://github.com/apache/samza/pull/467"},"issue":{"href":"https://api.github.com/repos/apache/samza/issues/467"},"comments":{"href":"https://api.github.com/repos/apache/samza/issues/467/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/samza/pulls/467/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/samza/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/samza/pulls/467/commits"},"statuses":{"href":"https://api.github.com/repos/apache/samza/statuses/634ab8d99b2282e785e3758602a0dcb01289b2c9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"srinipunuru"}}