{"action":"created","comment":{"url":"https://api.github.com/repos/github/statsd-ruby/pulls/comments/49462206","id":49462206,"diff_hunk":"@@ -14,14 +14,77 @@\n #   statsd = Statsd.new('localhost').tap{|sd| sd.namespace = 'account'}\n #   statsd.increment 'activate'\n class Statsd\n-  class RubyUdpClient\n-    attr_reader :key, :sock\n+  class BufferedUDPClient < UDPClient\n+    @max_packet_size = 511\n+    (class << self; attr_accessor :max_packet_size; end)\n \n-    def initialize(address, port, key = nil)\n+    def initialize(address, port)\n+      super(address, port)\n+      @buffer = String.new\n+    end\n+\n+    def flush!\n+      return unless @buffer.bytesize > 0\n+      sock.write(@buffer)\n+      @buffer.clear\n+    rescue => boom\n+      nil\n+    end\n+\n+    def send(msg)\n+      flush! if @buffer.bytesize + msg.bytesize > BufferedUDPClient.max_packet_size\n+      @buffer << msg\n+      @buffer << \"\\n\".freeze\n+      nil","path":"lib/statsd.rb","position":28,"original_position":28,"commit_id":"330b952ea1dcd258951f346b649582664d787373","original_commit_id":"330b952ea1dcd258951f346b649582664d787373","user":{"login":"vmg","id":42793,"avatar_url":"https://avatars.githubusercontent.com/u/42793?v=3","gravatar_id":"","url":"https://api.github.com/users/vmg","html_url":"https://github.com/vmg","followers_url":"https://api.github.com/users/vmg/followers","following_url":"https://api.github.com/users/vmg/following{/other_user}","gists_url":"https://api.github.com/users/vmg/gists{/gist_id}","starred_url":"https://api.github.com/users/vmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmg/subscriptions","organizations_url":"https://api.github.com/users/vmg/orgs","repos_url":"https://api.github.com/users/vmg/repos","events_url":"https://api.github.com/users/vmg/events{/privacy}","received_events_url":"https://api.github.com/users/vmg/received_events","type":"User","site_admin":true},"body":"Right. I agree. In practice this won't matter, because this is based around MTUs and affected by the network's congestion, but I agree that the semantics should be right. Let me fix it.","created_at":"2016-01-12T14:47:29Z","updated_at":"2016-01-12T14:47:29Z","html_url":"https://github.com/github/statsd-ruby/pull/18#discussion_r49462206","pull_request_url":"https://api.github.com/repos/github/statsd-ruby/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/github/statsd-ruby/pulls/comments/49462206"},"html":{"href":"https://github.com/github/statsd-ruby/pull/18#discussion_r49462206"},"pull_request":{"href":"https://api.github.com/repos/github/statsd-ruby/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/github/statsd-ruby/pulls/18","id":55762258,"html_url":"https://github.com/github/statsd-ruby/pull/18","diff_url":"https://github.com/github/statsd-ruby/pull/18.diff","patch_url":"https://github.com/github/statsd-ruby/pull/18.patch","issue_url":"https://api.github.com/repos/github/statsd-ruby/issues/18","number":18,"state":"open","locked":false,"title":"Buffered multi-metric packets","user":{"login":"vmg","id":42793,"avatar_url":"https://avatars.githubusercontent.com/u/42793?v=3","gravatar_id":"","url":"https://api.github.com/users/vmg","html_url":"https://github.com/vmg","followers_url":"https://api.github.com/users/vmg/followers","following_url":"https://api.github.com/users/vmg/following{/other_user}","gists_url":"https://api.github.com/users/vmg/gists{/gist_id}","starred_url":"https://api.github.com/users/vmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmg/subscriptions","organizations_url":"https://api.github.com/users/vmg/orgs","repos_url":"https://api.github.com/users/vmg/repos","events_url":"https://api.github.com/users/vmg/events{/privacy}","received_events_url":"https://api.github.com/users/vmg/received_events","type":"User","site_admin":true},"body":"This should greatly increase the throughput of the StatsD client and server. See the detailed commit messages for explanations and design decisions.\r\n\r\ncc @ross @aroben ","created_at":"2016-01-12T14:11:42Z","updated_at":"2016-01-12T14:47:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d094f6f77c0a22adb13455920bf7b6450e1602d2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/github/statsd-ruby/pulls/18/commits","review_comments_url":"https://api.github.com/repos/github/statsd-ruby/pulls/18/comments","review_comment_url":"https://api.github.com/repos/github/statsd-ruby/pulls/comments{/number}","comments_url":"https://api.github.com/repos/github/statsd-ruby/issues/18/comments","statuses_url":"https://api.github.com/repos/github/statsd-ruby/statuses/330b952ea1dcd258951f346b649582664d787373","head":{"label":"github:vmg/buffered","ref":"vmg/buffered","sha":"330b952ea1dcd258951f346b649582664d787373","user":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"repo":{"id":2185924,"name":"statsd-ruby","full_name":"github/statsd-ruby","owner":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/github/statsd-ruby","description":"A Ruby Statsd client.","fork":true,"url":"https://api.github.com/repos/github/statsd-ruby","forks_url":"https://api.github.com/repos/github/statsd-ruby/forks","keys_url":"https://api.github.com/repos/github/statsd-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/github/statsd-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/github/statsd-ruby/teams","hooks_url":"https://api.github.com/repos/github/statsd-ruby/hooks","issue_events_url":"https://api.github.com/repos/github/statsd-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/github/statsd-ruby/events","assignees_url":"https://api.github.com/repos/github/statsd-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/github/statsd-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/github/statsd-ruby/tags","blobs_url":"https://api.github.com/repos/github/statsd-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/github/statsd-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/github/statsd-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/github/statsd-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/github/statsd-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/github/statsd-ruby/languages","stargazers_url":"https://api.github.com/repos/github/statsd-ruby/stargazers","contributors_url":"https://api.github.com/repos/github/statsd-ruby/contributors","subscribers_url":"https://api.github.com/repos/github/statsd-ruby/subscribers","subscription_url":"https://api.github.com/repos/github/statsd-ruby/subscription","commits_url":"https://api.github.com/repos/github/statsd-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/github/statsd-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/github/statsd-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/github/statsd-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/github/statsd-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/github/statsd-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/github/statsd-ruby/merges","archive_url":"https://api.github.com/repos/github/statsd-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/github/statsd-ruby/downloads","issues_url":"https://api.github.com/repos/github/statsd-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/github/statsd-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/github/statsd-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/github/statsd-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/github/statsd-ruby/labels{/name}","releases_url":"https://api.github.com/repos/github/statsd-ruby/releases{/id}","created_at":"2011-08-10T15:35:44Z","updated_at":"2016-01-03T16:19:52Z","pushed_at":"2016-01-12T14:11:42Z","git_url":"git://github.com/github/statsd-ruby.git","ssh_url":"git@github.com:github/statsd-ruby.git","clone_url":"https://github.com/github/statsd-ruby.git","svn_url":"https://github.com/github/statsd-ruby","homepage":"","size":74,"stargazers_count":106,"watchers_count":106,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":3,"forks":29,"open_issues":3,"watchers":106,"default_branch":"master"}},"base":{"label":"github:master","ref":"master","sha":"1ddb9a4f8a840520580815c9457dd88a86657a62","user":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"repo":{"id":2185924,"name":"statsd-ruby","full_name":"github/statsd-ruby","owner":{"login":"github","id":9919,"avatar_url":"https://avatars.githubusercontent.com/u/9919?v=3","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/github/statsd-ruby","description":"A Ruby Statsd client.","fork":true,"url":"https://api.github.com/repos/github/statsd-ruby","forks_url":"https://api.github.com/repos/github/statsd-ruby/forks","keys_url":"https://api.github.com/repos/github/statsd-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/github/statsd-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/github/statsd-ruby/teams","hooks_url":"https://api.github.com/repos/github/statsd-ruby/hooks","issue_events_url":"https://api.github.com/repos/github/statsd-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/github/statsd-ruby/events","assignees_url":"https://api.github.com/repos/github/statsd-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/github/statsd-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/github/statsd-ruby/tags","blobs_url":"https://api.github.com/repos/github/statsd-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/github/statsd-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/github/statsd-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/github/statsd-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/github/statsd-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/github/statsd-ruby/languages","stargazers_url":"https://api.github.com/repos/github/statsd-ruby/stargazers","contributors_url":"https://api.github.com/repos/github/statsd-ruby/contributors","subscribers_url":"https://api.github.com/repos/github/statsd-ruby/subscribers","subscription_url":"https://api.github.com/repos/github/statsd-ruby/subscription","commits_url":"https://api.github.com/repos/github/statsd-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/github/statsd-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/github/statsd-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/github/statsd-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/github/statsd-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/github/statsd-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/github/statsd-ruby/merges","archive_url":"https://api.github.com/repos/github/statsd-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/github/statsd-ruby/downloads","issues_url":"https://api.github.com/repos/github/statsd-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/github/statsd-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/github/statsd-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/github/statsd-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/github/statsd-ruby/labels{/name}","releases_url":"https://api.github.com/repos/github/statsd-ruby/releases{/id}","created_at":"2011-08-10T15:35:44Z","updated_at":"2016-01-03T16:19:52Z","pushed_at":"2016-01-12T14:11:42Z","git_url":"git://github.com/github/statsd-ruby.git","ssh_url":"git@github.com:github/statsd-ruby.git","clone_url":"https://github.com/github/statsd-ruby.git","svn_url":"https://github.com/github/statsd-ruby","homepage":"","size":74,"stargazers_count":106,"watchers_count":106,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":3,"forks":29,"open_issues":3,"watchers":106,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/github/statsd-ruby/pulls/18"},"html":{"href":"https://github.com/github/statsd-ruby/pull/18"},"issue":{"href":"https://api.github.com/repos/github/statsd-ruby/issues/18"},"comments":{"href":"https://api.github.com/repos/github/statsd-ruby/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/github/statsd-ruby/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/github/statsd-ruby/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/github/statsd-ruby/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/github/statsd-ruby/statuses/330b952ea1dcd258951f346b649582664d787373"}}}}