Allow numeric statsd key name components
authorOri Livneh <ori@wikimedia.org>
Tue, 21 Jul 2015 19:40:20 +0000 (12:40 -0700)
committerOri Livneh <ori@wikimedia.org>
Tue, 21 Jul 2015 19:40:20 +0000 (12:40 -0700)
Make sure BufferingStatsdDataFactory::normalizeMetricKey() doesn't delete
digits in key names.

Change-Id: I22baa81a88a3e0bc0d5b8b58bd6bb922c58a3255

includes/libs/BufferingStatsdDataFactory.php

index 192b119..3d7fad5 100644 (file)
@@ -42,7 +42,7 @@ class BufferingStatsdDataFactory extends StatsdDataFactory {
        /**
         * Normalize a metric key for StatsD
         *
-        * Replace occurences of '::' with dots and any other non-alphabetic
+        * Replace occurences of '::' with dots and any other non-alphanumeric
         * characters with underscores. Combine runs of dots or underscores.
         * Then trim leading or trailing dots or underscores.
         *
@@ -51,7 +51,7 @@ class BufferingStatsdDataFactory extends StatsdDataFactory {
         */
        private static function normalizeMetricKey( $key ) {
                $key = preg_replace( '/[:.]+/', '.', $key );
-               $key = preg_replace( '/[^a-z.]+/i', '_', $key );
+               $key = preg_replace( '/[^a-z0-9.]+/i', '_', $key );
                $key = trim( $key, '_.' );
                return str_replace( array( '._', '_.' ), '.', $key );
        }