Wikia/app — pull request #3787 by drsnyder (2014-05-30 23:25:02+00:00)
Title: PLAT-170 Log sample of SQL queries w/ WikiaLogger

https://wikia-inc.atlassian.net/browse/PLATFORM-170

Inserted 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.

There 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()`.

To 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:

```PHP
$sampler = new BernoulliTrial(0.01);
if ($sampler->sample()) {
// do something 1% of the time
}
```

/cc @Wikia/platform-team