{"action":"created","comment":{"url":"https://api.github.com/repos/apache/beam/pulls/comments/104837472","pull_request_review_id":25690792,"id":104837472,"diff_hunk":"@@ -0,0 +1,60 @@\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, 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+package org.apache.beam.sdk.metrics;\n+\n+import java.util.concurrent.atomic.AtomicReference;\n+import org.apache.beam.sdk.annotations.Experimental;\n+\n+/**\n+ * Tracks the current value (and delta) for a {@link Gauge} metric.\n+ *\n+ * <p>This class generally shouldn't be used directly. The only exception is within a runner where\n+ * a gauge is being reported for a specific step (rather than the gauge in the current\n+ * context). In that case retrieving the underlying cell and reporting directly to it avoids a step\n+ * of indirection.\n+ */\n+@Experimental(Experimental.Kind.METRICS)\n+public class GaugeCell implements MetricCell<Gauge, GaugeData>, Gauge {\n+\n+  private final DirtyState dirty = new DirtyState();\n+  private final AtomicReference<GaugeData> gaugeValue = new AtomicReference<>(GaugeData.EMPTY);\n+\n+  @Override\n+  public void set(long value) {\n+    GaugeData original;\n+    do {\n+      original = gaugeValue.get();\n+    } while (!gaugeValue.compareAndSet(original, original.combine(GaugeData.create(value))));","path":"sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/GaugeCell.java","position":42,"original_position":42,"commit_id":"16b7e9c29d02e6b58fe6e6d937baba7360735435","original_commit_id":"16b7e9c29d02e6b58fe6e6d937baba7360735435","user":{"login":"aviemzur","id":5708714,"avatar_url":"https://avatars1.githubusercontent.com/u/5708714?v=3","gravatar_id":"","url":"https://api.github.com/users/aviemzur","html_url":"https://github.com/aviemzur","followers_url":"https://api.github.com/users/aviemzur/followers","following_url":"https://api.github.com/users/aviemzur/following{/other_user}","gists_url":"https://api.github.com/users/aviemzur/gists{/gist_id}","starred_url":"https://api.github.com/users/aviemzur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aviemzur/subscriptions","organizations_url":"https://api.github.com/users/aviemzur/orgs","repos_url":"https://api.github.com/users/aviemzur/repos","events_url":"https://api.github.com/users/aviemzur/events{/privacy}","received_events_url":"https://api.github.com/users/aviemzur/received_events","type":"User","site_admin":false},"body":"I'll add a call to `currentTimeMillis` in `GaugeCell#set`.\r\nI'll try to document that this can be affected by skewed clocks.","created_at":"2017-03-08T03:32:00Z","updated_at":"2017-03-08T03:32:00Z","html_url":"https://github.com/apache/beam/pull/2151#discussion_r104837472","pull_request_url":"https://api.github.com/repos/apache/beam/pulls/2151","_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/comments/104837472"},"html":{"href":"https://github.com/apache/beam/pull/2151#discussion_r104837472"},"pull_request":{"href":"https://api.github.com/repos/apache/beam/pulls/2151"}}},"pull_request":{"url":"https://api.github.com/repos/apache/beam/pulls/2151","id":108965885,"html_url":"https://github.com/apache/beam/pull/2151","diff_url":"https://github.com/apache/beam/pull/2151.diff","patch_url":"https://github.com/apache/beam/pull/2151.patch","issue_url":"https://api.github.com/repos/apache/beam/issues/2151","number":2151,"state":"open","locked":false,"title":"[BEAM-1617] Add Gauge metric type to Java SDK","user":{"login":"aviemzur","id":5708714,"avatar_url":"https://avatars1.githubusercontent.com/u/5708714?v=3","gravatar_id":"","url":"https://api.github.com/users/aviemzur","html_url":"https://github.com/aviemzur","followers_url":"https://api.github.com/users/aviemzur/followers","following_url":"https://api.github.com/users/aviemzur/following{/other_user}","gists_url":"https://api.github.com/users/aviemzur/gists{/gist_id}","starred_url":"https://api.github.com/users/aviemzur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aviemzur/subscriptions","organizations_url":"https://api.github.com/users/aviemzur/orgs","repos_url":"https://api.github.com/users/aviemzur/repos","events_url":"https://api.github.com/users/aviemzur/events{/privacy}","received_events_url":"https://api.github.com/users/aviemzur/received_events","type":"User","site_admin":false},"body":"Be sure to do all of the following to help us incorporate your contribution\r\nquickly and easily:\r\n\r\n - [x] Make sure the PR title is formatted like:\r\n   `[BEAM-<Jira issue #>] Description of pull request`\r\n - [x] Make sure tests pass via `mvn clean verify`. (Even better, enable\r\n       Travis-CI on your fork and ensure the whole test matrix passes).\r\n - [x] Replace `<Jira issue #>` in the title with the actual Jira issue\r\n       number, if there is one.\r\n - [ ] If this contribution is large, please file an Apache\r\n       [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.txt).\r\n\r\n---\r\n","created_at":"2017-03-03T12:43:02Z","updated_at":"2017-03-08T03:32:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dcf87c364caba856e1c325d8934665cce5269583","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/beam/pulls/2151/commits","review_comments_url":"https://api.github.com/repos/apache/beam/pulls/2151/comments","review_comment_url":"https://api.github.com/repos/apache/beam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/beam/issues/2151/comments","statuses_url":"https://api.github.com/repos/apache/beam/statuses/16b7e9c29d02e6b58fe6e6d937baba7360735435","head":{"label":"aviemzur:gauge-metric-type","ref":"gauge-metric-type","sha":"16b7e9c29d02e6b58fe6e6d937baba7360735435","user":{"login":"aviemzur","id":5708714,"avatar_url":"https://avatars1.githubusercontent.com/u/5708714?v=3","gravatar_id":"","url":"https://api.github.com/users/aviemzur","html_url":"https://github.com/aviemzur","followers_url":"https://api.github.com/users/aviemzur/followers","following_url":"https://api.github.com/users/aviemzur/following{/other_user}","gists_url":"https://api.github.com/users/aviemzur/gists{/gist_id}","starred_url":"https://api.github.com/users/aviemzur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aviemzur/subscriptions","organizations_url":"https://api.github.com/users/aviemzur/orgs","repos_url":"https://api.github.com/users/aviemzur/repos","events_url":"https://api.github.com/users/aviemzur/events{/privacy}","received_events_url":"https://api.github.com/users/aviemzur/received_events","type":"User","site_admin":false},"repo":{"id":66561709,"name":"beam","full_name":"aviemzur/beam","owner":{"login":"aviemzur","id":5708714,"avatar_url":"https://avatars1.githubusercontent.com/u/5708714?v=3","gravatar_id":"","url":"https://api.github.com/users/aviemzur","html_url":"https://github.com/aviemzur","followers_url":"https://api.github.com/users/aviemzur/followers","following_url":"https://api.github.com/users/aviemzur/following{/other_user}","gists_url":"https://api.github.com/users/aviemzur/gists{/gist_id}","starred_url":"https://api.github.com/users/aviemzur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aviemzur/subscriptions","organizations_url":"https://api.github.com/users/aviemzur/orgs","repos_url":"https://api.github.com/users/aviemzur/repos","events_url":"https://api.github.com/users/aviemzur/events{/privacy}","received_events_url":"https://api.github.com/users/aviemzur/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aviemzur/beam","description":"Mirror of Apache Beam (Incubating)","fork":true,"url":"https://api.github.com/repos/aviemzur/beam","forks_url":"https://api.github.com/repos/aviemzur/beam/forks","keys_url":"https://api.github.com/repos/aviemzur/beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aviemzur/beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aviemzur/beam/teams","hooks_url":"https://api.github.com/repos/aviemzur/beam/hooks","issue_events_url":"https://api.github.com/repos/aviemzur/beam/issues/events{/number}","events_url":"https://api.github.com/repos/aviemzur/beam/events","assignees_url":"https://api.github.com/repos/aviemzur/beam/assignees{/user}","branches_url":"https://api.github.com/repos/aviemzur/beam/branches{/branch}","tags_url":"https://api.github.com/repos/aviemzur/beam/tags","blobs_url":"https://api.github.com/repos/aviemzur/beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aviemzur/beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aviemzur/beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/aviemzur/beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aviemzur/beam/statuses/{sha}","languages_url":"https://api.github.com/repos/aviemzur/beam/languages","stargazers_url":"https://api.github.com/repos/aviemzur/beam/stargazers","contributors_url":"https://api.github.com/repos/aviemzur/beam/contributors","subscribers_url":"https://api.github.com/repos/aviemzur/beam/subscribers","subscription_url":"https://api.github.com/repos/aviemzur/beam/subscription","commits_url":"https://api.github.com/repos/aviemzur/beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/aviemzur/beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/aviemzur/beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/aviemzur/beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/aviemzur/beam/contents/{+path}","compare_url":"https://api.github.com/repos/aviemzur/beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aviemzur/beam/merges","archive_url":"https://api.github.com/repos/aviemzur/beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aviemzur/beam/downloads","issues_url":"https://api.github.com/repos/aviemzur/beam/issues{/number}","pulls_url":"https://api.github.com/repos/aviemzur/beam/pulls{/number}","milestones_url":"https://api.github.com/repos/aviemzur/beam/milestones{/number}","notifications_url":"https://api.github.com/repos/aviemzur/beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aviemzur/beam/labels{/name}","releases_url":"https://api.github.com/repos/aviemzur/beam/releases{/id}","deployments_url":"https://api.github.com/repos/aviemzur/beam/deployments","created_at":"2016-08-25T13:48:02Z","updated_at":"2017-02-06T18:31:17Z","pushed_at":"2017-03-07T13:43:13Z","git_url":"git://github.com/aviemzur/beam.git","ssh_url":"git@github.com:aviemzur/beam.git","clone_url":"https://github.com/aviemzur/beam.git","svn_url":"https://github.com/aviemzur/beam","homepage":null,"size":29342,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"1783819929bda5aaf34a7c176e11c2441d0a7346","user":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","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":50904245,"name":"beam","full_name":"apache/beam","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","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/beam","description":"Mirror of Apache Beam","fork":false,"url":"https://api.github.com/repos/apache/beam","forks_url":"https://api.github.com/repos/apache/beam/forks","keys_url":"https://api.github.com/repos/apache/beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/beam/teams","hooks_url":"https://api.github.com/repos/apache/beam/hooks","issue_events_url":"https://api.github.com/repos/apache/beam/issues/events{/number}","events_url":"https://api.github.com/repos/apache/beam/events","assignees_url":"https://api.github.com/repos/apache/beam/assignees{/user}","branches_url":"https://api.github.com/repos/apache/beam/branches{/branch}","tags_url":"https://api.github.com/repos/apache/beam/tags","blobs_url":"https://api.github.com/repos/apache/beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/beam/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/beam/languages","stargazers_url":"https://api.github.com/repos/apache/beam/stargazers","contributors_url":"https://api.github.com/repos/apache/beam/contributors","subscribers_url":"https://api.github.com/repos/apache/beam/subscribers","subscription_url":"https://api.github.com/repos/apache/beam/subscription","commits_url":"https://api.github.com/repos/apache/beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/beam/contents/{+path}","compare_url":"https://api.github.com/repos/apache/beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/beam/merges","archive_url":"https://api.github.com/repos/apache/beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/beam/downloads","issues_url":"https://api.github.com/repos/apache/beam/issues{/number}","pulls_url":"https://api.github.com/repos/apache/beam/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/beam/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/beam/labels{/name}","releases_url":"https://api.github.com/repos/apache/beam/releases{/id}","deployments_url":"https://api.github.com/repos/apache/beam/deployments","created_at":"2016-02-02T08:00:06Z","updated_at":"2017-03-08T02:51:50Z","pushed_at":"2017-03-08T02:53:57Z","git_url":"git://github.com/apache/beam.git","ssh_url":"git@github.com:apache/beam.git","clone_url":"https://github.com/apache/beam.git","svn_url":"https://github.com/apache/beam","homepage":"","size":29547,"stargazers_count":952,"watchers_count":952,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":503,"mirror_url":"git://git.apache.org/beam.git","open_issues_count":74,"forks":503,"open_issues":74,"watchers":952,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/2151"},"html":{"href":"https://github.com/apache/beam/pull/2151"},"issue":{"href":"https://api.github.com/repos/apache/beam/issues/2151"},"comments":{"href":"https://api.github.com/repos/apache/beam/issues/2151/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/beam/pulls/2151/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/beam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/beam/pulls/2151/commits"},"statuses":{"href":"https://api.github.com/repos/apache/beam/statuses/16b7e9c29d02e6b58fe6e6d937baba7360735435"}}}}
{"actor":{"display_login":"aviemzur"}}