GitHub PullRequestReviewCommentEvent at 2014-06-09 23:10:08
Repository: app
Actor: scottrabin
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/app/pulls/comments/13570111","id":13570111,"diff_hunk":"@@ -3479,4 +3479,48 @@ public function encodeExpiry( $expiry ) {\n \tpublic function setBigSelects( $value = true ) {\n \t\t// no-op\n \t}\n+\n+\n+\t/**\n+\t * Execute and profile the query. This is a wrapper for capturing timing information\n+\t * while executing a query.\n+\t *\n+\t * @param string $sql the query\n+\t * @param string $fname the function name\n+\t * @param bool $isMaster is this against the master\n+\t *\n+\t * @return ResultWrapper see doQuery\n+\t */\n+\tprotected function executeAndProfileQuery( $sql, $fname, $isMaster ) {\n+\t\t$queryId = MWDebug::query( $sql, $fname, $isMaster );\n+\t\t$start = microtime(true);\n+\n+\t\t$ret = $this->doQuery( $sql );\n+\n+\t\t$this->logSql( $sql, $fname, microtime(true) - $start, $isMaster );\n+\n+\t\tMWDebug::queryTime( $queryId );\n+\t\treturn $ret;\n+\t}\n+\n+\t/**\n+\t * Log a SQL statement. This function does not log every statement but samples\n+\t * at the rate defined in self::QUERY_SAMPLE_RATE.\n+\t *\n+\t * @param string $sql the query\n+\t * @param string $fname the function name\n+\t * @param bool $isMaster is this against the master\n+\t * @return void\n+\t */\n+\tprotected function logSql( $sql, $fname, $elapsedTime, $isMaster ) {\n+\t\t$sampler = new BernoulliTrial(self::QUERY_SAMPLE_RATE);","path":"includes/db/Database.php","position":80,"original_position":80,"commit_id":"da5f829b565f93b514047c27bcc40d75d0dbc1ff","original_commit_id":"da5f829b565f93b514047c27bcc40d75d0dbc1ff","user":{"login":"scottrabin","id":791631,"avatar_url":"https://avatars.githubusercontent.com/u/791631?","gravatar_id":"dc9a529c704690c9d8467f61f3efb5d4","url":"https://api.github.com/users/scottrabin","html_url":"https://github.com/scottrabin","followers_url":"https://api.github.com/users/scottrabin/followers","following_url":"https://api.github.com/users/scottrabin/following{/other_user}","gists_url":"https://api.github.com/users/scottrabin/gists{/gist_id}","starred_url":"https://api.github.com/users/scottrabin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottrabin/subscriptions","organizations_url":"https://api.github.com/users/scottrabin/orgs","repos_url":"https://api.github.com/users/scottrabin/repos","events_url":"https://api.github.com/users/scottrabin/events{/privacy}","received_events_url":"https://api.github.com/users/scottrabin/received_events","type":"User","site_admin":false},"body":"Which requires that you either hold on to the reference or add the boiler plate for each call to re-instantiate the object each time...","created_at":"2014-06-09T23:10:08Z","updated_at":"2014-06-09T23:10:08Z","html_url":"https://github.com/Wikia/app/pull/3787#discussion_r13570111","pull_request_url":"https://api.github.com/repos/Wikia/app/pulls/3787","_links":{"self":{"href":"https://api.github.com/repos/Wikia/app/pulls/comments/13570111"},"html":{"href":"https://github.com/Wikia/app/pull/3787#discussion_r13570111"},"pull_request":{"href":"https://api.github.com/repos/Wikia/app/pulls/3787"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/app/pulls/3787","id":16560200,"html_url":"https://github.com/Wikia/app/pull/3787","diff_url":"https://github.com/Wikia/app/pull/3787.diff","patch_url":"https://github.com/Wikia/app/pull/3787.patch","issue_url":"https://api.github.com/repos/Wikia/app/issues/3787","number":3787,"state":"open","title":"PLAT-170 Log sample of SQL queries w/ WikiaLogger","user":{"login":"drsnyder","id":21621,"avatar_url":"https://avatars.githubusercontent.com/u/21621?","gravatar_id":"9823ac5f556df92f382f874f9eed87ab","url":"https://api.github.com/users/drsnyder","html_url":"https://github.com/drsnyder","followers_url":"https://api.github.com/users/drsnyder/followers","following_url":"https://api.github.com/users/drsnyder/following{/other_user}","gists_url":"https://api.github.com/users/drsnyder/gists{/gist_id}","starred_url":"https://api.github.com/users/drsnyder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drsnyder/subscriptions","organizations_url":"https://api.github.com/users/drsnyder/orgs","repos_url":"https://api.github.com/users/drsnyder/repos","events_url":"https://api.github.com/users/drsnyder/events{/privacy}","received_events_url":"https://api.github.com/users/drsnyder/received_events","type":"User","site_admin":false},"body":"https://wikia-inc.atlassian.net/browse/PLATFORM-170\r\n\r\nInserted random (at a rate of 1%) sampling of SQL queries in DatabaseBase around doQuery. The instrumentation adds the query, the execution time, the function, and the server role to the log payload. With this in place, we can query using Kibana for the URL, the query string, the server, the db name the calling method:function, and the elapsed time.\r\n\r\nThere was some existing profiling happening using `MWDebug::query()` which was left intact. To keep the already extremely long `query()` method from expanding, I moved the instrumentation and logging into a wrapper function called `executeAndProfileQuery()`.\r\n\r\nTo enable sampling a Bernoulli trial class is being added under `\\Wikia\\Util\\Statistics\\BernoulliTrial`. This class allows you to randomly sample events at a specified rate. For example, if a developer wanted to sample an event 1% of the time they could:\r\n\r\n```PHP\r\n$sampler = new BernoulliTrial(0.01);\r\nif ($sampler->sample()) {\r\n   // do something 1% of the time\r\n}\r\n``` \r\n\r\n/cc @Wikia/platform-team ","created_at":"2014-05-30T23:25:02Z","updated_at":"2014-06-09T23:10:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a3dcf70fd9bd47e000288fc692acfddac26d27e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/app/pulls/3787/commits","review_comments_url":"https://api.github.com/repos/Wikia/app/pulls/3787/comments","review_comment_url":"https://api.github.com/repos/Wikia/app/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Wikia/app/issues/3787/comments","statuses_url":"https://api.github.com/repos/Wikia/app/statuses/da5f829b565f93b514047c27bcc40d75d0dbc1ff","head":{"label":"Wikia:PLAT-170","ref":"PLAT-170","sha":"da5f829b565f93b514047c27bcc40d75d0dbc1ff","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?","gravatar_id":"7d465709e42f40da92f14aae7e005558","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":5532313,"name":"app","full_name":"Wikia/app","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?","gravatar_id":"7d465709e42f40da92f14aae7e005558","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/app","description":"Wikia Application Code","fork":false,"url":"https://api.github.com/repos/Wikia/app","forks_url":"https://api.github.com/repos/Wikia/app/forks","keys_url":"https://api.github.com/repos/Wikia/app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/app/teams","hooks_url":"https://api.github.com/repos/Wikia/app/hooks","issue_events_url":"https://api.github.com/repos/Wikia/app/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/app/events","assignees_url":"https://api.github.com/repos/Wikia/app/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/app/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/app/tags","blobs_url":"https://api.github.com/repos/Wikia/app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/app/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/app/languages","stargazers_url":"https://api.github.com/repos/Wikia/app/stargazers","contributors_url":"https://api.github.com/repos/Wikia/app/contributors","subscribers_url":"https://api.github.com/repos/Wikia/app/subscribers","subscription_url":"https://api.github.com/repos/Wikia/app/subscription","commits_url":"https://api.github.com/repos/Wikia/app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/app/issues/comments/{number}","contents_url":"https://api.github.com/repos/Wikia/app/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/app/merges","archive_url":"https://api.github.com/repos/Wikia/app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/app/downloads","issues_url":"https://api.github.com/repos/Wikia/app/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/app/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/app/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/app/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/app/releases{/id}","created_at":"2012-08-23T20:55:58Z","updated_at":"2014-06-09T22:42:24Z","pushed_at":"2014-06-09T22:42:23Z","git_url":"git://github.com/Wikia/app.git","ssh_url":"git@github.com:Wikia/app.git","clone_url":"https://github.com/Wikia/app.git","svn_url":"https://github.com/Wikia/app","homepage":"http://dev.wikia.com","size":690646,"stargazers_count":58,"watchers_count":58,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":40,"mirror_url":null,"open_issues_count":64,"forks":40,"open_issues":64,"watchers":58,"default_branch":"dev"}},"base":{"label":"Wikia:dev","ref":"dev","sha":"f4920641360075c6e965504cc16981beab6480a7","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?","gravatar_id":"7d465709e42f40da92f14aae7e005558","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":5532313,"name":"app","full_name":"Wikia/app","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?","gravatar_id":"7d465709e42f40da92f14aae7e005558","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/app","description":"Wikia Application Code","fork":false,"url":"https://api.github.com/repos/Wikia/app","forks_url":"https://api.github.com/repos/Wikia/app/forks","keys_url":"https://api.github.com/repos/Wikia/app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/app/teams","hooks_url":"https://api.github.com/repos/Wikia/app/hooks","issue_events_url":"https://api.github.com/repos/Wikia/app/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/app/events","assignees_url":"https://api.github.com/repos/Wikia/app/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/app/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/app/tags","blobs_url":"https://api.github.com/repos/Wikia/app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/app/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/app/languages","stargazers_url":"https://api.github.com/repos/Wikia/app/stargazers","contributors_url":"https://api.github.com/repos/Wikia/app/contributors","subscribers_url":"https://api.github.com/repos/Wikia/app/subscribers","subscription_url":"https://api.github.com/repos/Wikia/app/subscription","commits_url":"https://api.github.com/repos/Wikia/app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/app/issues/comments/{number}","contents_url":"https://api.github.com/repos/Wikia/app/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/app/merges","archive_url":"https://api.github.com/repos/Wikia/app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/app/downloads","issues_url":"https://api.github.com/repos/Wikia/app/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/app/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/app/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/app/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/app/releases{/id}","created_at":"2012-08-23T20:55:58Z","updated_at":"2014-06-09T22:42:24Z","pushed_at":"2014-06-09T22:42:23Z","git_url":"git://github.com/Wikia/app.git","ssh_url":"git@github.com:Wikia/app.git","clone_url":"https://github.com/Wikia/app.git","svn_url":"https://github.com/Wikia/app","homepage":"http://dev.wikia.com","size":690646,"stargazers_count":58,"watchers_count":58,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":40,"mirror_url":null,"open_issues_count":64,"forks":40,"open_issues":64,"watchers":58,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/app/pulls/3787"},"html":{"href":"https://github.com/Wikia/app/pull/3787"},"issue":{"href":"https://api.github.com/repos/Wikia/app/issues/3787"},"comments":{"href":"https://api.github.com/repos/Wikia/app/issues/3787/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/app/pulls/3787/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/app/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Wikia/app/pulls/3787/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/app/statuses/da5f829b565f93b514047c27bcc40d75d0dbc1ff"}}}}