{"action":"closed","number":323,"pull_request":{"url":"https://api.github.com/repos/etsy/statsd/pulls/323","id":7337230,"html_url":"https://github.com/etsy/statsd/pull/323","diff_url":"https://github.com/etsy/statsd/pull/323.diff","patch_url":"https://github.com/etsy/statsd/pull/323.patch","issue_url":"https://api.github.com/repos/etsy/statsd/issues/323","number":323,"state":"closed","locked":false,"title":"Composition Engine","user":{"login":"thiagocaiubi","id":15719,"avatar_url":"https://avatars.githubusercontent.com/u/15719?v=3","gravatar_id":"","url":"https://api.github.com/users/thiagocaiubi","html_url":"https://github.com/thiagocaiubi","followers_url":"https://api.github.com/users/thiagocaiubi/followers","following_url":"https://api.github.com/users/thiagocaiubi/following{/other_user}","gists_url":"https://api.github.com/users/thiagocaiubi/gists{/gist_id}","starred_url":"https://api.github.com/users/thiagocaiubi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thiagocaiubi/subscriptions","organizations_url":"https://api.github.com/users/thiagocaiubi/orgs","repos_url":"https://api.github.com/users/thiagocaiubi/repos","events_url":"https://api.github.com/users/thiagocaiubi/events{/privacy}","received_events_url":"https://api.github.com/users/thiagocaiubi/received_events","type":"User","site_admin":false},"body":"Here at Chaordic we use Librato and Graphite. Librato for several reasons. As you all know Librato can't compose metrics using functions like Graphite (ex.: Graph Data > Apply Function > Calculate > Ratio). So we built an engine to compose metrics based on existing ones. \r\nMetrics are sent to the composition engine before flushing it to backends. Compositions are calculate based on rules defined at a source file. For example: \r\n\r\nRule:\r\n```javascript\r\n{\r\n      name: \"#0.ctr.#1\",\r\n      regexp:[\r\n        /^([a-z]+)\\.click\\.([a-z]+)/,\r\n        /^([a-z]+)\\.view\\.([a-z]+)/\r\n      ],\r\n      compose: function(click, view) {\r\n        return 100 * (click / view);\r\n      }\r\n}\r\n```\r\n\r\nSource Metrics:\r\n```javascript\r\n{\r\n    counters: {\r\n        \"site.click.page\": 10,\r\n        \"site.view.page\": 100\r\n    }\r\n}\r\n````\r\n\r\n\r\nThe engine will store it matching metric to an array [10, 100] where 10 is the first matching regexp and 100 is the second matching regexp. After all matches in metrics the engine starting applying collected metrics to user-defined compose functions. So it will become:\r\n\r\n```javascript\r\nclick = 10;\r\nview = 100;\r\n```\r\n\r\nApplied to: \r\n\r\n```javascript\r\ncompose: function(click, view) {\r\n    return 100 * (click / view);\r\n}\r\n```\r\n\r\nWill result: 10\r\n\r\nThe output compose metric will be named like name attribute defined in the rule object. The sharps are back reference to the matching strings, so: \r\n\r\n#0 = site\r\n#1 = page\r\n\r\nThen, output metric will be:\r\n\r\nsite.ctr.page = 10\r\n\r\nThe final metrics object to be flushed to backends will look like:\r\n\r\n```javascript\r\n{\r\n    counters: {\r\n        \"site.click.page\": 10,\r\n        \"site.view.page\": 100,\r\n        \"site.ctr.page\": 100\r\n    }\r\n}\r\n````\r\n\r\nCheers!","created_at":"2013-08-01T21:52:01Z","updated_at":"2016-06-08T16:44:03Z","closed_at":"2016-06-08T16:44:03Z","merged_at":null,"merge_commit_sha":"3e125b0565b56f4848f9aced6216dbc9fbb0dd87","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/etsy/statsd/pulls/323/commits","review_comments_url":"https://api.github.com/repos/etsy/statsd/pulls/323/comments","review_comment_url":"https://api.github.com/repos/etsy/statsd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/etsy/statsd/issues/323/comments","statuses_url":"https://api.github.com/repos/etsy/statsd/statuses/fb7f47e408c0702ac914e21312bb41ea0be41132","head":{"label":"chaordic:master","ref":"master","sha":"fb7f47e408c0702ac914e21312bb41ea0be41132","user":{"login":"chaordic","id":1434501,"avatar_url":"https://avatars.githubusercontent.com/u/1434501?v=3","gravatar_id":"","url":"https://api.github.com/users/chaordic","html_url":"https://github.com/chaordic","followers_url":"https://api.github.com/users/chaordic/followers","following_url":"https://api.github.com/users/chaordic/following{/other_user}","gists_url":"https://api.github.com/users/chaordic/gists{/gist_id}","starred_url":"https://api.github.com/users/chaordic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaordic/subscriptions","organizations_url":"https://api.github.com/users/chaordic/orgs","repos_url":"https://api.github.com/users/chaordic/repos","events_url":"https://api.github.com/users/chaordic/events{/privacy}","received_events_url":"https://api.github.com/users/chaordic/received_events","type":"Organization","site_admin":false},"repo":{"id":11749718,"name":"statsd","full_name":"chaordic/statsd","owner":{"login":"chaordic","id":1434501,"avatar_url":"https://avatars.githubusercontent.com/u/1434501?v=3","gravatar_id":"","url":"https://api.github.com/users/chaordic","html_url":"https://github.com/chaordic","followers_url":"https://api.github.com/users/chaordic/followers","following_url":"https://api.github.com/users/chaordic/following{/other_user}","gists_url":"https://api.github.com/users/chaordic/gists{/gist_id}","starred_url":"https://api.github.com/users/chaordic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaordic/subscriptions","organizations_url":"https://api.github.com/users/chaordic/orgs","repos_url":"https://api.github.com/users/chaordic/repos","events_url":"https://api.github.com/users/chaordic/events{/privacy}","received_events_url":"https://api.github.com/users/chaordic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chaordic/statsd","description":"Simple daemon for easy stats aggregation","fork":true,"url":"https://api.github.com/repos/chaordic/statsd","forks_url":"https://api.github.com/repos/chaordic/statsd/forks","keys_url":"https://api.github.com/repos/chaordic/statsd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chaordic/statsd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chaordic/statsd/teams","hooks_url":"https://api.github.com/repos/chaordic/statsd/hooks","issue_events_url":"https://api.github.com/repos/chaordic/statsd/issues/events{/number}","events_url":"https://api.github.com/repos/chaordic/statsd/events","assignees_url":"https://api.github.com/repos/chaordic/statsd/assignees{/user}","branches_url":"https://api.github.com/repos/chaordic/statsd/branches{/branch}","tags_url":"https://api.github.com/repos/chaordic/statsd/tags","blobs_url":"https://api.github.com/repos/chaordic/statsd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chaordic/statsd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chaordic/statsd/git/refs{/sha}","trees_url":"https://api.github.com/repos/chaordic/statsd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chaordic/statsd/statuses/{sha}","languages_url":"https://api.github.com/repos/chaordic/statsd/languages","stargazers_url":"https://api.github.com/repos/chaordic/statsd/stargazers","contributors_url":"https://api.github.com/repos/chaordic/statsd/contributors","subscribers_url":"https://api.github.com/repos/chaordic/statsd/subscribers","subscription_url":"https://api.github.com/repos/chaordic/statsd/subscription","commits_url":"https://api.github.com/repos/chaordic/statsd/commits{/sha}","git_commits_url":"https://api.github.com/repos/chaordic/statsd/git/commits{/sha}","comments_url":"https://api.github.com/repos/chaordic/statsd/comments{/number}","issue_comment_url":"https://api.github.com/repos/chaordic/statsd/issues/comments{/number}","contents_url":"https://api.github.com/repos/chaordic/statsd/contents/{+path}","compare_url":"https://api.github.com/repos/chaordic/statsd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chaordic/statsd/merges","archive_url":"https://api.github.com/repos/chaordic/statsd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chaordic/statsd/downloads","issues_url":"https://api.github.com/repos/chaordic/statsd/issues{/number}","pulls_url":"https://api.github.com/repos/chaordic/statsd/pulls{/number}","milestones_url":"https://api.github.com/repos/chaordic/statsd/milestones{/number}","notifications_url":"https://api.github.com/repos/chaordic/statsd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chaordic/statsd/labels{/name}","releases_url":"https://api.github.com/repos/chaordic/statsd/releases{/id}","deployments_url":"https://api.github.com/repos/chaordic/statsd/deployments","created_at":"2013-07-29T21:01:23Z","updated_at":"2014-04-11T13:54:46Z","pushed_at":"2015-04-01T20:49:57Z","git_url":"git://github.com/chaordic/statsd.git","ssh_url":"git@github.com:chaordic/statsd.git","clone_url":"https://github.com/chaordic/statsd.git","svn_url":"https://github.com/chaordic/statsd","homepage":"","size":744,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"etsy:master","ref":"master","sha":"e4c957fb4fa7b5697eb7f61b97f7dd0f82f86d93","user":{"login":"etsy","id":193389,"avatar_url":"https://avatars.githubusercontent.com/u/193389?v=3","gravatar_id":"","url":"https://api.github.com/users/etsy","html_url":"https://github.com/etsy","followers_url":"https://api.github.com/users/etsy/followers","following_url":"https://api.github.com/users/etsy/following{/other_user}","gists_url":"https://api.github.com/users/etsy/gists{/gist_id}","starred_url":"https://api.github.com/users/etsy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etsy/subscriptions","organizations_url":"https://api.github.com/users/etsy/orgs","repos_url":"https://api.github.com/users/etsy/repos","events_url":"https://api.github.com/users/etsy/events{/privacy}","received_events_url":"https://api.github.com/users/etsy/received_events","type":"Organization","site_admin":false},"repo":{"id":1207300,"name":"statsd","full_name":"etsy/statsd","owner":{"login":"etsy","id":193389,"avatar_url":"https://avatars.githubusercontent.com/u/193389?v=3","gravatar_id":"","url":"https://api.github.com/users/etsy","html_url":"https://github.com/etsy","followers_url":"https://api.github.com/users/etsy/followers","following_url":"https://api.github.com/users/etsy/following{/other_user}","gists_url":"https://api.github.com/users/etsy/gists{/gist_id}","starred_url":"https://api.github.com/users/etsy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etsy/subscriptions","organizations_url":"https://api.github.com/users/etsy/orgs","repos_url":"https://api.github.com/users/etsy/repos","events_url":"https://api.github.com/users/etsy/events{/privacy}","received_events_url":"https://api.github.com/users/etsy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/etsy/statsd","description":"Daemon for easy but powerful stats aggregation","fork":false,"url":"https://api.github.com/repos/etsy/statsd","forks_url":"https://api.github.com/repos/etsy/statsd/forks","keys_url":"https://api.github.com/repos/etsy/statsd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/etsy/statsd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/etsy/statsd/teams","hooks_url":"https://api.github.com/repos/etsy/statsd/hooks","issue_events_url":"https://api.github.com/repos/etsy/statsd/issues/events{/number}","events_url":"https://api.github.com/repos/etsy/statsd/events","assignees_url":"https://api.github.com/repos/etsy/statsd/assignees{/user}","branches_url":"https://api.github.com/repos/etsy/statsd/branches{/branch}","tags_url":"https://api.github.com/repos/etsy/statsd/tags","blobs_url":"https://api.github.com/repos/etsy/statsd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/etsy/statsd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/etsy/statsd/git/refs{/sha}","trees_url":"https://api.github.com/repos/etsy/statsd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/etsy/statsd/statuses/{sha}","languages_url":"https://api.github.com/repos/etsy/statsd/languages","stargazers_url":"https://api.github.com/repos/etsy/statsd/stargazers","contributors_url":"https://api.github.com/repos/etsy/statsd/contributors","subscribers_url":"https://api.github.com/repos/etsy/statsd/subscribers","subscription_url":"https://api.github.com/repos/etsy/statsd/subscription","commits_url":"https://api.github.com/repos/etsy/statsd/commits{/sha}","git_commits_url":"https://api.github.com/repos/etsy/statsd/git/commits{/sha}","comments_url":"https://api.github.com/repos/etsy/statsd/comments{/number}","issue_comment_url":"https://api.github.com/repos/etsy/statsd/issues/comments{/number}","contents_url":"https://api.github.com/repos/etsy/statsd/contents/{+path}","compare_url":"https://api.github.com/repos/etsy/statsd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/etsy/statsd/merges","archive_url":"https://api.github.com/repos/etsy/statsd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/etsy/statsd/downloads","issues_url":"https://api.github.com/repos/etsy/statsd/issues{/number}","pulls_url":"https://api.github.com/repos/etsy/statsd/pulls{/number}","milestones_url":"https://api.github.com/repos/etsy/statsd/milestones{/number}","notifications_url":"https://api.github.com/repos/etsy/statsd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/etsy/statsd/labels{/name}","releases_url":"https://api.github.com/repos/etsy/statsd/releases{/id}","deployments_url":"https://api.github.com/repos/etsy/statsd/deployments","created_at":"2010-12-30T00:09:50Z","updated_at":"2016-06-08T15:07:10Z","pushed_at":"2016-05-13T18:34:02Z","git_url":"git://github.com/etsy/statsd.git","ssh_url":"git@github.com:etsy/statsd.git","clone_url":"https://github.com/etsy/statsd.git","svn_url":"https://github.com/etsy/statsd","homepage":"","size":2109,"stargazers_count":9852,"watchers_count":9852,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1350,"mirror_url":null,"open_issues_count":48,"forks":1350,"open_issues":48,"watchers":9852,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/etsy/statsd/pulls/323"},"html":{"href":"https://github.com/etsy/statsd/pull/323"},"issue":{"href":"https://api.github.com/repos/etsy/statsd/issues/323"},"comments":{"href":"https://api.github.com/repos/etsy/statsd/issues/323/comments"},"review_comments":{"href":"https://api.github.com/repos/etsy/statsd/pulls/323/comments"},"review_comment":{"href":"https://api.github.com/repos/etsy/statsd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/etsy/statsd/pulls/323/commits"},"statuses":{"href":"https://api.github.com/repos/etsy/statsd/statuses/fb7f47e408c0702ac914e21312bb41ea0be41132"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":3,"review_comments":0,"commits":2,"additions":118,"deletions":2,"changed_files":4}}
{"actor":{"display_login":"thiagocaiubi"}}