{"action":"created","comment":{"url":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/comments/206597088","pull_request_review_id":142039615,"id":206597088,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjU5NzA4OA==","diff_hunk":"@@ -14,12 +14,86 @@\n  * limitations under the License.\n  */\n \n-import {AggregationData, Measurement} from './types';\n+import {AggregationData, AggregationType, CountData, DistributionData, LastValueData, Measurement, SumData} from './types';\n \n export class Recorder {\n   static addMeasurement(\n       aggregationData: AggregationData,\n       measurement: Measurement): AggregationData {\n-    throw new Error('Not Implemented');\n+    switch (aggregationData.type) {\n+      case AggregationType.DISTRIBUTION:\n+        return this.addToDistribution(\n+            aggregationData as DistributionData, measurement);\n+\n+      case AggregationType.SUM:\n+        return this.addToSum(aggregationData as SumData, measurement);\n+\n+      case AggregationType.COUNT:\n+        return this.addToCount(aggregationData as CountData, measurement);\n+\n+      default:\n+        return this.addToLastValue(\n+            aggregationData as LastValueData, measurement);\n+    }\n+  }\n+\n+  private static addToDistribution(\n+      distributionData: DistributionData,\n+      measurement: Measurement): DistributionData {\n+    distributionData.timestamp = Date.now();\n+\n+    distributionData.count += 1;\n+\n+    const inletBucket = distributionData.buckets.find((bucket) => {\n+      return bucket.lowBoundary <= measurement.value &&\n+          measurement.value < bucket.highBoundary;\n+    });\n+    inletBucket.count += 1;\n+\n+    if (measurement.value > distributionData.max) {\n+      distributionData.max = measurement.value;\n+    }\n+\n+    if (measurement.value < distributionData.min) {\n+      distributionData.min = measurement.value;\n+    }\n+\n+    if (distributionData.count === 1) {\n+      distributionData.mean = measurement.value;\n+    }\n+\n+    distributionData.sum += measurement.value;\n+\n+    const oldMean = distributionData.mean;\n+    distributionData.mean = distributionData.mean +","path":"packages/opencensus-core/src/stats/recorder.ts","position":57,"original_position":57,"commit_id":"d30c442a10a500ffc30fdb9f07ad38e399ef60c8","original_commit_id":"d30c442a10a500ffc30fdb9f07ad38e399ef60c8","user":{"login":"kjin","id":2365820,"node_id":"MDQ6VXNlcjIzNjU4MjA=","avatar_url":"https://avatars3.githubusercontent.com/u/2365820?v=4","gravatar_id":"","url":"https://api.github.com/users/kjin","html_url":"https://github.com/kjin","followers_url":"https://api.github.com/users/kjin/followers","following_url":"https://api.github.com/users/kjin/following{/other_user}","gists_url":"https://api.github.com/users/kjin/gists{/gist_id}","starred_url":"https://api.github.com/users/kjin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjin/subscriptions","organizations_url":"https://api.github.com/users/kjin/orgs","repos_url":"https://api.github.com/users/kjin/repos","events_url":"https://api.github.com/users/kjin/events{/privacy}","received_events_url":"https://api.github.com/users/kjin/received_events","type":"User","site_admin":false},"body":"Overflow is a good concern that I didn't think about. In that case I am more ambivalent, and incrementing might just as good given that it stays consistent with stdev. It will not be completely accurate for Double values but maybe that is more acceptable.","created_at":"2018-07-31T16:30:09Z","updated_at":"2018-07-31T16:30:10Z","html_url":"https://github.com/census-instrumentation/opencensus-node/pull/85#discussion_r206597088","pull_request_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/85","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/comments/206597088"},"html":{"href":"https://github.com/census-instrumentation/opencensus-node/pull/85#discussion_r206597088"},"pull_request":{"href":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/85"}},"in_reply_to_id":206361845},"pull_request":{"url":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/85","id":204758168,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0NzU4MTY4","html_url":"https://github.com/census-instrumentation/opencensus-node/pull/85","diff_url":"https://github.com/census-instrumentation/opencensus-node/pull/85.diff","patch_url":"https://github.com/census-instrumentation/opencensus-node/pull/85.patch","issue_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/issues/85","number":85,"state":"open","locked":false,"title":"feat: add stats recorder implementation","user":{"login":"eduardoemery","id":37382770,"node_id":"MDQ6VXNlcjM3MzgyNzcw","avatar_url":"https://avatars3.githubusercontent.com/u/37382770?v=4","gravatar_id":"","url":"https://api.github.com/users/eduardoemery","html_url":"https://github.com/eduardoemery","followers_url":"https://api.github.com/users/eduardoemery/followers","following_url":"https://api.github.com/users/eduardoemery/following{/other_user}","gists_url":"https://api.github.com/users/eduardoemery/gists{/gist_id}","starred_url":"https://api.github.com/users/eduardoemery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduardoemery/subscriptions","organizations_url":"https://api.github.com/users/eduardoemery/orgs","repos_url":"https://api.github.com/users/eduardoemery/repos","events_url":"https://api.github.com/users/eduardoemery/events{/privacy}","received_events_url":"https://api.github.com/users/eduardoemery/received_events","type":"User","site_admin":false},"body":"- Add the `recorder` implementation\r\n- Adds `recorder` tests\r\n- Refactors code\r\n    - removes `bucketsBoundaries`\r\n    - changes `bucket.max` to `bucket.highBoundary`\r\n    - changes `bucket.min` to `bucket.lowBoundary`","created_at":"2018-07-30T10:20:23Z","updated_at":"2018-07-31T16:30:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb4b5baa06868b6dc142529e5aa38db9669fdf51","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":925574611,"node_id":"MDU6TGFiZWw5MjU1NzQ2MTE=","url":"https://api.github.com/repos/census-instrumentation/opencensus-node/labels/cla:%20yes","name":"cla: yes","color":"14a839","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/85/commits","review_comments_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/85/comments","review_comment_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/issues/85/comments","statuses_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/statuses/d30c442a10a500ffc30fdb9f07ad38e399ef60c8","head":{"label":"CESARBR:stats_recorder","ref":"stats_recorder","sha":"d30c442a10a500ffc30fdb9f07ad38e399ef60c8","user":{"login":"CESARBR","id":7859691,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc4NTk2OTE=","avatar_url":"https://avatars2.githubusercontent.com/u/7859691?v=4","gravatar_id":"","url":"https://api.github.com/users/CESARBR","html_url":"https://github.com/CESARBR","followers_url":"https://api.github.com/users/CESARBR/followers","following_url":"https://api.github.com/users/CESARBR/following{/other_user}","gists_url":"https://api.github.com/users/CESARBR/gists{/gist_id}","starred_url":"https://api.github.com/users/CESARBR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CESARBR/subscriptions","organizations_url":"https://api.github.com/users/CESARBR/orgs","repos_url":"https://api.github.com/users/CESARBR/repos","events_url":"https://api.github.com/users/CESARBR/events{/privacy}","received_events_url":"https://api.github.com/users/CESARBR/received_events","type":"Organization","site_admin":false},"repo":{"id":134257961,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQyNTc5NjE=","name":"opencensus-node","full_name":"CESARBR/opencensus-node","owner":{"login":"CESARBR","id":7859691,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc4NTk2OTE=","avatar_url":"https://avatars2.githubusercontent.com/u/7859691?v=4","gravatar_id":"","url":"https://api.github.com/users/CESARBR","html_url":"https://github.com/CESARBR","followers_url":"https://api.github.com/users/CESARBR/followers","following_url":"https://api.github.com/users/CESARBR/following{/other_user}","gists_url":"https://api.github.com/users/CESARBR/gists{/gist_id}","starred_url":"https://api.github.com/users/CESARBR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CESARBR/subscriptions","organizations_url":"https://api.github.com/users/CESARBR/orgs","repos_url":"https://api.github.com/users/CESARBR/repos","events_url":"https://api.github.com/users/CESARBR/events{/privacy}","received_events_url":"https://api.github.com/users/CESARBR/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CESARBR/opencensus-node","description":null,"fork":true,"url":"https://api.github.com/repos/CESARBR/opencensus-node","forks_url":"https://api.github.com/repos/CESARBR/opencensus-node/forks","keys_url":"https://api.github.com/repos/CESARBR/opencensus-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CESARBR/opencensus-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CESARBR/opencensus-node/teams","hooks_url":"https://api.github.com/repos/CESARBR/opencensus-node/hooks","issue_events_url":"https://api.github.com/repos/CESARBR/opencensus-node/issues/events{/number}","events_url":"https://api.github.com/repos/CESARBR/opencensus-node/events","assignees_url":"https://api.github.com/repos/CESARBR/opencensus-node/assignees{/user}","branches_url":"https://api.github.com/repos/CESARBR/opencensus-node/branches{/branch}","tags_url":"https://api.github.com/repos/CESARBR/opencensus-node/tags","blobs_url":"https://api.github.com/repos/CESARBR/opencensus-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CESARBR/opencensus-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CESARBR/opencensus-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/CESARBR/opencensus-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CESARBR/opencensus-node/statuses/{sha}","languages_url":"https://api.github.com/repos/CESARBR/opencensus-node/languages","stargazers_url":"https://api.github.com/repos/CESARBR/opencensus-node/stargazers","contributors_url":"https://api.github.com/repos/CESARBR/opencensus-node/contributors","subscribers_url":"https://api.github.com/repos/CESARBR/opencensus-node/subscribers","subscription_url":"https://api.github.com/repos/CESARBR/opencensus-node/subscription","commits_url":"https://api.github.com/repos/CESARBR/opencensus-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/CESARBR/opencensus-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/CESARBR/opencensus-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/CESARBR/opencensus-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/CESARBR/opencensus-node/contents/{+path}","compare_url":"https://api.github.com/repos/CESARBR/opencensus-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CESARBR/opencensus-node/merges","archive_url":"https://api.github.com/repos/CESARBR/opencensus-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CESARBR/opencensus-node/downloads","issues_url":"https://api.github.com/repos/CESARBR/opencensus-node/issues{/number}","pulls_url":"https://api.github.com/repos/CESARBR/opencensus-node/pulls{/number}","milestones_url":"https://api.github.com/repos/CESARBR/opencensus-node/milestones{/number}","notifications_url":"https://api.github.com/repos/CESARBR/opencensus-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CESARBR/opencensus-node/labels{/name}","releases_url":"https://api.github.com/repos/CESARBR/opencensus-node/releases{/id}","deployments_url":"https://api.github.com/repos/CESARBR/opencensus-node/deployments","created_at":"2018-05-21T11:07:13Z","updated_at":"2018-07-20T18:30:24Z","pushed_at":"2018-07-30T19:00:29Z","git_url":"git://github.com/CESARBR/opencensus-node.git","ssh_url":"git@github.com:CESARBR/opencensus-node.git","clone_url":"https://github.com/CESARBR/opencensus-node.git","svn_url":"https://github.com/CESARBR/opencensus-node","homepage":null,"size":1448,"stargazers_count":3,"watchers_count":3,"language":"TypeScript","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":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"census-instrumentation:master","ref":"master","sha":"0da334ab10d5de4bff7dfb717903188453c61baa","user":{"login":"census-instrumentation","id":26944525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2OTQ0NTI1","avatar_url":"https://avatars0.githubusercontent.com/u/26944525?v=4","gravatar_id":"","url":"https://api.github.com/users/census-instrumentation","html_url":"https://github.com/census-instrumentation","followers_url":"https://api.github.com/users/census-instrumentation/followers","following_url":"https://api.github.com/users/census-instrumentation/following{/other_user}","gists_url":"https://api.github.com/users/census-instrumentation/gists{/gist_id}","starred_url":"https://api.github.com/users/census-instrumentation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/census-instrumentation/subscriptions","organizations_url":"https://api.github.com/users/census-instrumentation/orgs","repos_url":"https://api.github.com/users/census-instrumentation/repos","events_url":"https://api.github.com/users/census-instrumentation/events{/privacy}","received_events_url":"https://api.github.com/users/census-instrumentation/received_events","type":"Organization","site_admin":false},"repo":{"id":109782875,"node_id":"MDEwOlJlcG9zaXRvcnkxMDk3ODI4NzU=","name":"opencensus-node","full_name":"census-instrumentation/opencensus-node","owner":{"login":"census-instrumentation","id":26944525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2OTQ0NTI1","avatar_url":"https://avatars0.githubusercontent.com/u/26944525?v=4","gravatar_id":"","url":"https://api.github.com/users/census-instrumentation","html_url":"https://github.com/census-instrumentation","followers_url":"https://api.github.com/users/census-instrumentation/followers","following_url":"https://api.github.com/users/census-instrumentation/following{/other_user}","gists_url":"https://api.github.com/users/census-instrumentation/gists{/gist_id}","starred_url":"https://api.github.com/users/census-instrumentation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/census-instrumentation/subscriptions","organizations_url":"https://api.github.com/users/census-instrumentation/orgs","repos_url":"https://api.github.com/users/census-instrumentation/repos","events_url":"https://api.github.com/users/census-instrumentation/events{/privacy}","received_events_url":"https://api.github.com/users/census-instrumentation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/census-instrumentation/opencensus-node","description":"A stats collection and distributed tracing framework","fork":false,"url":"https://api.github.com/repos/census-instrumentation/opencensus-node","forks_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/forks","keys_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/teams","hooks_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/hooks","issue_events_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/issues/events{/number}","events_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/events","assignees_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/assignees{/user}","branches_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/branches{/branch}","tags_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/tags","blobs_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/statuses/{sha}","languages_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/languages","stargazers_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/stargazers","contributors_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/contributors","subscribers_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/subscribers","subscription_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/subscription","commits_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/contents/{+path}","compare_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/merges","archive_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/downloads","issues_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/issues{/number}","pulls_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls{/number}","milestones_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/milestones{/number}","notifications_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/labels{/name}","releases_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/releases{/id}","deployments_url":"https://api.github.com/repos/census-instrumentation/opencensus-node/deployments","created_at":"2017-11-07T03:35:31Z","updated_at":"2018-07-31T02:59:33Z","pushed_at":"2018-07-31T09:54:40Z","git_url":"git://github.com/census-instrumentation/opencensus-node.git","ssh_url":"git@github.com:census-instrumentation/opencensus-node.git","clone_url":"https://github.com/census-instrumentation/opencensus-node.git","svn_url":"https://github.com/census-instrumentation/opencensus-node","homepage":"https://opencensus.io","size":1252,"stargazers_count":54,"watchers_count":54,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":18,"open_issues":18,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/85"},"html":{"href":"https://github.com/census-instrumentation/opencensus-node/pull/85"},"issue":{"href":"https://api.github.com/repos/census-instrumentation/opencensus-node/issues/85"},"comments":{"href":"https://api.github.com/repos/census-instrumentation/opencensus-node/issues/85/comments"},"review_comments":{"href":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/85/comments"},"review_comment":{"href":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/census-instrumentation/opencensus-node/pulls/85/commits"},"statuses":{"href":"https://api.github.com/repos/census-instrumentation/opencensus-node/statuses/d30c442a10a500ffc30fdb9f07ad38e399ef60c8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kjin"}}