Ori.livneh has submitted this change and it was merged.

Change subject: Don't bother buffering a counter update with a delta of zero.
......................................................................


Don't bother buffering a counter update with a delta of zero.

Counter updates with a delta of zero don't do anything, so there's no point in
sending them over the wire.

Change-Id: Iae82ee9c9a8544c94abfcbdf944bd713687dce9d
(cherry picked from commit f1381932df78afcdc3ccfb2f356ec93d81f7ad24)
---
M includes/libs/BufferingStatsdDataFactory.php
1 file changed, 8 insertions(+), 2 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/libs/BufferingStatsdDataFactory.php 
b/includes/libs/BufferingStatsdDataFactory.php
index ea5b09d..457237a 100644
--- a/includes/libs/BufferingStatsdDataFactory.php
+++ b/includes/libs/BufferingStatsdDataFactory.php
@@ -20,7 +20,9 @@
  * @file
  */
 
+use Liuggio\StatsdClient\Entity\StatsdDataInterface;
 use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+
 
 /**
  * A factory for application metric data.
@@ -38,8 +40,8 @@
                $this->prefix = $prefix;
        }
 
-       public function produceStatsdData( $key, $value = 1, $metric = 
self::STATSD_METRIC_COUNT ) {
-               $this->buffer[] = $entity = $this->produceStatsdDataEntity();
+       public function produceStatsdData( $key, $value = 1, $metric = 
StatsdDataInterface::STATSD_METRIC_COUNT ) {
+               $entity = $this->produceStatsdDataEntity();
                if ( $key !== null ) {
                        $prefixedKey = ltrim( $this->prefix . '.' . $key, '.' );
                        $entity->setKey( $prefixedKey );
@@ -50,6 +52,10 @@
                if ( $metric !== null ) {
                        $entity->setMetric( $metric );
                }
+               // Don't bother buffering a counter update with a delta of zero.
+               if ( !( $metric === StatsdDataInterface::STATSD_METRIC_COUNT && 
!$value ) ) {
+                       $this->buffer[] = $entity;
+               }
                return $entity;
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/204619
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iae82ee9c9a8544c94abfcbdf944bd713687dce9d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.26wmf1
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to