MediaWiki REL1_39
|
Detect high-contention DB queries via profiling calls. More...
Public Member Functions | |
__construct () | |
recordConnection ( $server, $db, bool $isPrimary) | |
Mark a DB as having been connected to with a new handle. | |
recordQueryCompletion ( $query, float $sTime, bool $isWrite, ?int $rowCount, string $trxId, ?string $serverName=null) | |
Register the name and time of a method for slow DB trx detection. | |
redefineExpectations (array $expects, string $fname) | |
Clear all expectations and hit counters and set new performance expectations. | |
resetExpectations () | |
Reset all performance expectations and hit counters. | |
setExpectation (string $event, $limit, string $fname) | |
Set performance expectations. | |
setExpectations (array $expects, string $fname) | |
Set one or multiple performance expectations. | |
setLogger (LoggerInterface $logger) | |
setSilenced (bool $value) | |
silenceForScope () | |
Disable the logging of warnings until the returned object goes out of scope or is consumed. | |
transactionWritingIn ( $server, $db, string $id) | |
Mark a DB as in a transaction with one or more writes pending. | |
transactionWritingOut ( $server, $db, string $id, float $writeTime, int $affected) | |
Mark a DB as no longer in a transaction. | |
Detect high-contention DB queries via profiling calls.
This class is meant to work with an IDatabase object, which manages queries.
Definition at line 38 of file TransactionProfiler.php.
Wikimedia\Rdbms\TransactionProfiler::__construct | ( | ) |
Definition at line 91 of file TransactionProfiler.php.
References Wikimedia\Rdbms\TransactionProfiler\setLogger().
Wikimedia\Rdbms\TransactionProfiler::recordConnection | ( | $server, | |
$db, | |||
bool | $isPrimary ) |
Mark a DB as having been connected to with a new handle.
Note that there can be multiple connections to a single DB.
string | $server | DB server |
string | null | $db | DB name |
bool | $isPrimary |
Definition at line 207 of file TransactionProfiler.php.
Wikimedia\Rdbms\TransactionProfiler::recordQueryCompletion | ( | $query, | |
float | $sTime, | ||
bool | $isWrite, | ||
?int | $rowCount, | ||
string | $trxId, | ||
?string | $serverName = null ) |
Register the name and time of a method for slow DB trx detection.
This assumes that all queries are synchronous (non-overlapping)
string | GeneralizedSql | $query | Function name or generalized SQL |
float | $sTime | Starting UNIX wall time |
bool | $isWrite | Whether this is a write query |
int | null | $rowCount | Number of affected/read rows |
string | $trxId | Transaction id |
string | null | $serverName | db host name like db1234 |
Definition at line 265 of file TransactionProfiler.php.
Wikimedia\Rdbms\TransactionProfiler::redefineExpectations | ( | array | $expects, |
string | $fname ) |
Clear all expectations and hit counters and set new performance expectations.
Use this to apply a totally different set of expectations for a different part of the request, such as during "post-send" (execution after HTTP response completion)
array | $expects | Map of (event => limit) |
string | $fname |
Definition at line 193 of file TransactionProfiler.php.
References Wikimedia\Rdbms\TransactionProfiler\setExpectations().
Wikimedia\Rdbms\TransactionProfiler::resetExpectations | ( | ) |
Reset all performance expectations and hit counters.
Use this for unit testing or before applying a totally different set of expectations for a different part of the request, such as during "post-send" (execution after HTTP response completion)
Definition at line 179 of file TransactionProfiler.php.
Wikimedia\Rdbms\TransactionProfiler::setExpectation | ( | string | $event, |
$limit, | |||
string | $fname ) |
Set performance expectations.
With conflicting expectations, the most narrow ones will be used
string | $event | One of the names in TransactionProfiler::EVENT_NAMES |
float | int | $limit | Maximum event count, event value, or total event value |
string | $fname | Caller |
Definition at line 139 of file TransactionProfiler.php.
Referenced by Wikimedia\Rdbms\TransactionProfiler\setExpectations().
Wikimedia\Rdbms\TransactionProfiler::setExpectations | ( | array | $expects, |
string | $fname ) |
Set one or multiple performance expectations.
With conflicting expectations, the most narrow ones will be used
Use this to initialize expectations or make them stricter mid-request
array | $expects | Map of (event => limit) |
string | $fname |
Definition at line 164 of file TransactionProfiler.php.
References Wikimedia\Rdbms\TransactionProfiler\setExpectation().
Referenced by Wikimedia\Rdbms\TransactionProfiler\redefineExpectations().
Wikimedia\Rdbms\TransactionProfiler::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 102 of file TransactionProfiler.php.
Referenced by Wikimedia\Rdbms\TransactionProfiler\__construct().
Wikimedia\Rdbms\TransactionProfiler::setSilenced | ( | bool | $value | ) |
bool | $value |
Definition at line 111 of file TransactionProfiler.php.
Referenced by Wikimedia\Rdbms\TransactionProfiler\silenceForScope().
Wikimedia\Rdbms\TransactionProfiler::silenceForScope | ( | ) |
Disable the logging of warnings until the returned object goes out of scope or is consumed.
Definition at line 122 of file TransactionProfiler.php.
References Wikimedia\Rdbms\TransactionProfiler\setSilenced().
Wikimedia\Rdbms\TransactionProfiler::transactionWritingIn | ( | $server, | |
$db, | |||
string | $id ) |
Mark a DB as in a transaction with one or more writes pending.
Note that there can be multiple connections to a single DB.
string | $server | DB server |
string | null | $db | DB name |
string | $id | ID string of transaction |
Definition at line 236 of file TransactionProfiler.php.
Wikimedia\Rdbms\TransactionProfiler::transactionWritingOut | ( | $server, | |
$db, | |||
string | $id, | ||
float | $writeTime, | ||
int | $affected ) |
Mark a DB as no longer in a transaction.
This will check if locks are possibly held for longer than needed and log any affected transactions to a special DB log. Note that there can be multiple connections to a single DB.
string | $server | DB server |
string | null | $db | DB name |
string | $id | ID string of transaction |
float | $writeTime | Time spent in write queries |
int | $affected | Number of rows affected by writes |
Definition at line 339 of file TransactionProfiler.php.