{"action":"created","comment":{"url":"https://api.github.com/repos/statful/statful-client-java/pulls/comments/84447674","pull_request_review_id":5225961,"id":84447674,"diff_hunk":"@@ -134,33 +181,46 @@ private int sanitizeSampleRate(final int sampleRate) {\n     }\n \n     private void putRaw(final String metric) {\n-\n-        boolean inserted = buffer.offer(metric);\n+        boolean inserted = standardBuffer.addToBuffer(metric);\n         if (!inserted) {\n+            // We should discard older metrics instead\n             LOGGER.warning(\"The buffer is full, metric ignored!.\");\n         }\n-        if (isTimeToFlush()) {\n+\n+        if (standardBuffer.isTimeToFlush()) {\n             flush();\n         }\n     }\n \n-    private boolean isTimeToFlush() {\n-        int bufferSize = buffer.size();\n-        return bufferSize > 0 && flushSize <= bufferSize;\n+    private void putAggregatedRaw(final String metric, final Aggregation aggregation, final AggregationFrequency aggregationFrequency) {\n+        boolean inserted = aggregatedBuffer.addToBuffer(metric, aggregation, aggregationFrequency);\n+        if (!inserted) {\n+            // We should discard older metrics instead\n+            LOGGER.warning(\"The buffer is full, metric ignored!.\");\n+        }\n+\n+        if (aggregatedBuffer.isTimeToFlush()) {\n+            flush();\n+        }\n     }\n \n     private void flush() {\n-        String message = getMessageBuffer();\n-        if (!message.isEmpty()) {\n-            sendMetric(message);\n+        String standardMessages = standardBuffer.readBuffer();\n+        if (!standardMessages.isEmpty()) {\n+            sendMetric(standardMessages);\n         }\n-    }\n \n-    @Override\n-    public final void forceSyncFlush() {\n-        String message = getMessageBuffer();\n-        if (!message.isEmpty()) {\n-            sendMetricSynchronously(message);\n+        Set<Aggregation> aggregations = aggregatedBuffer.getAggregations();\n+\n+        for (Aggregation aggregation : aggregations) {","path":"core/src/main/java/com/statful/client/core/sender/BufferedMetricsSender.java","position":209,"original_position":209,"commit_id":"65a29924a58328f1d775fceb8e1b5aaa3a592fc8","original_commit_id":"65a29924a58328f1d775fceb8e1b5aaa3a592fc8","user":{"login":"brunopalos","id":3313946,"avatar_url":"https://avatars.githubusercontent.com/u/3313946?v=3","gravatar_id":"","url":"https://api.github.com/users/brunopalos","html_url":"https://github.com/brunopalos","followers_url":"https://api.github.com/users/brunopalos/followers","following_url":"https://api.github.com/users/brunopalos/following{/other_user}","gists_url":"https://api.github.com/users/brunopalos/gists{/gist_id}","starred_url":"https://api.github.com/users/brunopalos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunopalos/subscriptions","organizations_url":"https://api.github.com/users/brunopalos/orgs","repos_url":"https://api.github.com/users/brunopalos/repos","events_url":"https://api.github.com/users/brunopalos/events{/privacy}","received_events_url":"https://api.github.com/users/brunopalos/received_events","type":"User","site_admin":false},"body":"See my comments above.","created_at":"2016-10-21T09:32:42Z","updated_at":"2016-10-21T09:32:42Z","html_url":"https://github.com/statful/statful-client-java/pull/2#discussion_r84447674","pull_request_url":"https://api.github.com/repos/statful/statful-client-java/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/statful/statful-client-java/pulls/comments/84447674"},"html":{"href":"https://github.com/statful/statful-client-java/pull/2#discussion_r84447674"},"pull_request":{"href":"https://api.github.com/repos/statful/statful-client-java/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/statful/statful-client-java/pulls/2","id":89438088,"html_url":"https://github.com/statful/statful-client-java/pull/2","diff_url":"https://github.com/statful/statful-client-java/pull/2.diff","patch_url":"https://github.com/statful/statful-client-java/pull/2.patch","issue_url":"https://api.github.com/repos/statful/statful-client-java/issues/2","number":2,"state":"open","locked":false,"title":"feat(NA) - Support for aggregated metrics.","user":{"login":"miguelcnf","id":994805,"avatar_url":"https://avatars.githubusercontent.com/u/994805?v=3","gravatar_id":"","url":"https://api.github.com/users/miguelcnf","html_url":"https://github.com/miguelcnf","followers_url":"https://api.github.com/users/miguelcnf/followers","following_url":"https://api.github.com/users/miguelcnf/following{/other_user}","gists_url":"https://api.github.com/users/miguelcnf/gists{/gist_id}","starred_url":"https://api.github.com/users/miguelcnf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miguelcnf/subscriptions","organizations_url":"https://api.github.com/users/miguelcnf/orgs","repos_url":"https://api.github.com/users/miguelcnf/repos","events_url":"https://api.github.com/users/miguelcnf/events{/privacy}","received_events_url":"https://api.github.com/users/miguelcnf/received_events","type":"User","site_admin":false},"body":"As the title says this adds support for the aggregated metric methods, although they're not in the spec I've tried to follow what we did on the nodejs client adapting to the inner works of this implementation.\r\n\r\nNot happy with some of decisions I had to make to get this off the ground, namely throwing `UnsupportedOperationException` when the transport or the client implementations of the correspondent interfaces are incompatible. We can revisit this later once we get the spec updated accordingly.\r\n\r\nPlease have a look.","created_at":"2016-10-14T19:07:54Z","updated_at":"2016-10-21T09:32:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2dc6cf2d90536528cf6f1d7388e9879a8c82b2ca","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/statful/statful-client-java/pulls/2/commits","review_comments_url":"https://api.github.com/repos/statful/statful-client-java/pulls/2/comments","review_comment_url":"https://api.github.com/repos/statful/statful-client-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/statful/statful-client-java/issues/2/comments","statuses_url":"https://api.github.com/repos/statful/statful-client-java/statuses/65a29924a58328f1d775fceb8e1b5aaa3a592fc8","head":{"label":"statful:support-aggregated-metrics","ref":"support-aggregated-metrics","sha":"65a29924a58328f1d775fceb8e1b5aaa3a592fc8","user":{"login":"statful","id":20299158,"avatar_url":"https://avatars.githubusercontent.com/u/20299158?v=3","gravatar_id":"","url":"https://api.github.com/users/statful","html_url":"https://github.com/statful","followers_url":"https://api.github.com/users/statful/followers","following_url":"https://api.github.com/users/statful/following{/other_user}","gists_url":"https://api.github.com/users/statful/gists{/gist_id}","starred_url":"https://api.github.com/users/statful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/statful/subscriptions","organizations_url":"https://api.github.com/users/statful/orgs","repos_url":"https://api.github.com/users/statful/repos","events_url":"https://api.github.com/users/statful/events{/privacy}","received_events_url":"https://api.github.com/users/statful/received_events","type":"Organization","site_admin":false},"repo":{"id":64424185,"name":"statful-client-java","full_name":"statful/statful-client-java","owner":{"login":"statful","id":20299158,"avatar_url":"https://avatars.githubusercontent.com/u/20299158?v=3","gravatar_id":"","url":"https://api.github.com/users/statful","html_url":"https://github.com/statful","followers_url":"https://api.github.com/users/statful/followers","following_url":"https://api.github.com/users/statful/following{/other_user}","gists_url":"https://api.github.com/users/statful/gists{/gist_id}","starred_url":"https://api.github.com/users/statful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/statful/subscriptions","organizations_url":"https://api.github.com/users/statful/orgs","repos_url":"https://api.github.com/users/statful/repos","events_url":"https://api.github.com/users/statful/events{/privacy}","received_events_url":"https://api.github.com/users/statful/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/statful/statful-client-java","description":"Statful client for Java applications","fork":false,"url":"https://api.github.com/repos/statful/statful-client-java","forks_url":"https://api.github.com/repos/statful/statful-client-java/forks","keys_url":"https://api.github.com/repos/statful/statful-client-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/statful/statful-client-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/statful/statful-client-java/teams","hooks_url":"https://api.github.com/repos/statful/statful-client-java/hooks","issue_events_url":"https://api.github.com/repos/statful/statful-client-java/issues/events{/number}","events_url":"https://api.github.com/repos/statful/statful-client-java/events","assignees_url":"https://api.github.com/repos/statful/statful-client-java/assignees{/user}","branches_url":"https://api.github.com/repos/statful/statful-client-java/branches{/branch}","tags_url":"https://api.github.com/repos/statful/statful-client-java/tags","blobs_url":"https://api.github.com/repos/statful/statful-client-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/statful/statful-client-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/statful/statful-client-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/statful/statful-client-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/statful/statful-client-java/statuses/{sha}","languages_url":"https://api.github.com/repos/statful/statful-client-java/languages","stargazers_url":"https://api.github.com/repos/statful/statful-client-java/stargazers","contributors_url":"https://api.github.com/repos/statful/statful-client-java/contributors","subscribers_url":"https://api.github.com/repos/statful/statful-client-java/subscribers","subscription_url":"https://api.github.com/repos/statful/statful-client-java/subscription","commits_url":"https://api.github.com/repos/statful/statful-client-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/statful/statful-client-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/statful/statful-client-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/statful/statful-client-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/statful/statful-client-java/contents/{+path}","compare_url":"https://api.github.com/repos/statful/statful-client-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/statful/statful-client-java/merges","archive_url":"https://api.github.com/repos/statful/statful-client-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/statful/statful-client-java/downloads","issues_url":"https://api.github.com/repos/statful/statful-client-java/issues{/number}","pulls_url":"https://api.github.com/repos/statful/statful-client-java/pulls{/number}","milestones_url":"https://api.github.com/repos/statful/statful-client-java/milestones{/number}","notifications_url":"https://api.github.com/repos/statful/statful-client-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/statful/statful-client-java/labels{/name}","releases_url":"https://api.github.com/repos/statful/statful-client-java/releases{/id}","deployments_url":"https://api.github.com/repos/statful/statful-client-java/deployments","created_at":"2016-07-28T19:56:26Z","updated_at":"2016-10-11T17:39:24Z","pushed_at":"2016-10-20T18:35:06Z","git_url":"git://github.com/statful/statful-client-java.git","ssh_url":"git@github.com:statful/statful-client-java.git","clone_url":"https://github.com/statful/statful-client-java.git","svn_url":"https://github.com/statful/statful-client-java","homepage":null,"size":328,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":6,"default_branch":"master"}},"base":{"label":"statful:master","ref":"master","sha":"4f050df26b45ffa707d9b5f8969f446cea3b6c19","user":{"login":"statful","id":20299158,"avatar_url":"https://avatars.githubusercontent.com/u/20299158?v=3","gravatar_id":"","url":"https://api.github.com/users/statful","html_url":"https://github.com/statful","followers_url":"https://api.github.com/users/statful/followers","following_url":"https://api.github.com/users/statful/following{/other_user}","gists_url":"https://api.github.com/users/statful/gists{/gist_id}","starred_url":"https://api.github.com/users/statful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/statful/subscriptions","organizations_url":"https://api.github.com/users/statful/orgs","repos_url":"https://api.github.com/users/statful/repos","events_url":"https://api.github.com/users/statful/events{/privacy}","received_events_url":"https://api.github.com/users/statful/received_events","type":"Organization","site_admin":false},"repo":{"id":64424185,"name":"statful-client-java","full_name":"statful/statful-client-java","owner":{"login":"statful","id":20299158,"avatar_url":"https://avatars.githubusercontent.com/u/20299158?v=3","gravatar_id":"","url":"https://api.github.com/users/statful","html_url":"https://github.com/statful","followers_url":"https://api.github.com/users/statful/followers","following_url":"https://api.github.com/users/statful/following{/other_user}","gists_url":"https://api.github.com/users/statful/gists{/gist_id}","starred_url":"https://api.github.com/users/statful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/statful/subscriptions","organizations_url":"https://api.github.com/users/statful/orgs","repos_url":"https://api.github.com/users/statful/repos","events_url":"https://api.github.com/users/statful/events{/privacy}","received_events_url":"https://api.github.com/users/statful/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/statful/statful-client-java","description":"Statful client for Java applications","fork":false,"url":"https://api.github.com/repos/statful/statful-client-java","forks_url":"https://api.github.com/repos/statful/statful-client-java/forks","keys_url":"https://api.github.com/repos/statful/statful-client-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/statful/statful-client-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/statful/statful-client-java/teams","hooks_url":"https://api.github.com/repos/statful/statful-client-java/hooks","issue_events_url":"https://api.github.com/repos/statful/statful-client-java/issues/events{/number}","events_url":"https://api.github.com/repos/statful/statful-client-java/events","assignees_url":"https://api.github.com/repos/statful/statful-client-java/assignees{/user}","branches_url":"https://api.github.com/repos/statful/statful-client-java/branches{/branch}","tags_url":"https://api.github.com/repos/statful/statful-client-java/tags","blobs_url":"https://api.github.com/repos/statful/statful-client-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/statful/statful-client-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/statful/statful-client-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/statful/statful-client-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/statful/statful-client-java/statuses/{sha}","languages_url":"https://api.github.com/repos/statful/statful-client-java/languages","stargazers_url":"https://api.github.com/repos/statful/statful-client-java/stargazers","contributors_url":"https://api.github.com/repos/statful/statful-client-java/contributors","subscribers_url":"https://api.github.com/repos/statful/statful-client-java/subscribers","subscription_url":"https://api.github.com/repos/statful/statful-client-java/subscription","commits_url":"https://api.github.com/repos/statful/statful-client-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/statful/statful-client-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/statful/statful-client-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/statful/statful-client-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/statful/statful-client-java/contents/{+path}","compare_url":"https://api.github.com/repos/statful/statful-client-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/statful/statful-client-java/merges","archive_url":"https://api.github.com/repos/statful/statful-client-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/statful/statful-client-java/downloads","issues_url":"https://api.github.com/repos/statful/statful-client-java/issues{/number}","pulls_url":"https://api.github.com/repos/statful/statful-client-java/pulls{/number}","milestones_url":"https://api.github.com/repos/statful/statful-client-java/milestones{/number}","notifications_url":"https://api.github.com/repos/statful/statful-client-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/statful/statful-client-java/labels{/name}","releases_url":"https://api.github.com/repos/statful/statful-client-java/releases{/id}","deployments_url":"https://api.github.com/repos/statful/statful-client-java/deployments","created_at":"2016-07-28T19:56:26Z","updated_at":"2016-10-11T17:39:24Z","pushed_at":"2016-10-20T18:35:06Z","git_url":"git://github.com/statful/statful-client-java.git","ssh_url":"git@github.com:statful/statful-client-java.git","clone_url":"https://github.com/statful/statful-client-java.git","svn_url":"https://github.com/statful/statful-client-java","homepage":null,"size":328,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/statful/statful-client-java/pulls/2"},"html":{"href":"https://github.com/statful/statful-client-java/pull/2"},"issue":{"href":"https://api.github.com/repos/statful/statful-client-java/issues/2"},"comments":{"href":"https://api.github.com/repos/statful/statful-client-java/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/statful/statful-client-java/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/statful/statful-client-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/statful/statful-client-java/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/statful/statful-client-java/statuses/65a29924a58328f1d775fceb8e1b5aaa3a592fc8"}}}}
{"actor":{"display_login":"brunopalos"}}