jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/344472 )
Change subject: Send integer ms to DB lag time guage instead of seconds
......................................................................
Send integer ms to DB lag time guage instead of seconds
Previously, this sent the floating point value in seconds,
which is not what statsd expects here.
Bug: T149210
Change-Id: I8fcd58d7c9e183952df1257b1520d9426a42fd26
---
M maintenance/getLagTimes.php
1 file changed, 27 insertions(+), 20 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/maintenance/getLagTimes.php b/maintenance/getLagTimes.php
index 677bfa2..ad2fdf8 100644
--- a/maintenance/getLagTimes.php
+++ b/maintenance/getLagTimes.php
@@ -38,30 +38,37 @@
}
public function execute() {
- $lbFactory =
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
- $stats =
MediaWikiServices::getInstance()->getStatsdDataFactory();
+ $services = MediaWikiServices::getInstance();
+ $lbFactory = $services->getDBLoadBalancerFactory();
+ $stats = $services->getStatsdDataFactory();
+ $lbsByType = [
+ 'main' => $lbFactory->getAllMainLBs(),
+ 'external' => $lbFactory->getAllExternalLBs()
+ ];
- $lbs = $lbFactory->getAllMainLBs() +
$lbFactory->getAllExternalLBs();
- foreach ( $lbs as $cluster => $lb ) {
- if ( $lb->getServerCount() <= 1 ) {
- continue;
- }
- $lags = $lb->getLagTimes();
- foreach ( $lags as $serverIndex => $lag ) {
- $host = $lb->getServerName( $serverIndex );
- if ( IP::isValid( $host ) ) {
- $ip = $host;
- $host = gethostbyaddr( $host );
- } else {
- $ip = gethostbyname( $host );
+ foreach ( $lbsByType as $type => $lbs ) {
+ foreach ( $lbs as $cluster => $lb ) {
+ if ( $lb->getServerCount() <= 1 ) {
+ continue;
}
+ $lags = $lb->getLagTimes();
+ foreach ( $lags as $serverIndex => $lag ) {
+ $host = $lb->getServerName(
$serverIndex );
+ if ( IP::isValid( $host ) ) {
+ $ip = $host;
+ $host = gethostbyaddr( $host );
+ } else {
+ $ip = gethostbyname( $host );
+ }
- $starLen = min( intval( $lag ), 40 );
- $stars = str_repeat( '*', $starLen );
- $this->output( sprintf( "%10s %20s %3d %s\n",
$ip, $host, $lag, $stars ) );
+ $starLen = min( intval( $lag ), 40 );
+ $stars = str_repeat( '*', $starLen );
+ $this->output( sprintf( "%10s %20s %3d
%s\n", $ip, $host, $lag, $stars ) );
- if ( $this->hasOption( 'report' ) ) {
- $stats->gauge(
"loadbalancer.lag.$cluster.$host", $lag );
+ if ( $this->hasOption( 'report' ) ) {
+ $group = ( $type === 'external'
) ? 'external' : $cluster;
+ $stats->gauge(
"loadbalancer.lag.$group.$host", intval( $lag * 1e3 ) );
+ }
}
}
}
--
To view, visit https://gerrit.wikimedia.org/r/344472
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8fcd58d7c9e183952df1257b1520d9426a42fd26
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Jcrespo <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits