From: Ori Livneh Date: Thu, 14 May 2015 21:49:51 +0000 (-0700) Subject: ProfilerOutputStats: tweak stat key normalization X-Git-Tag: 1.31.0-rc.0~11406 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/message.php?a=commitdiff_plain;h=dfa5dabd159f9e423ffe22ee063196a7ca09787c;p=lhc%2Fweb%2Fwiklou.git ProfilerOutputStats: tweak stat key normalization When we convert a profiler entry to a statsd metric key, we replace nonalphabetic characters with slashes. When part of the key is a file path with a leading or trailing slash, this can result in keys that look like: 'MediaWiki._srv_mediawiki_foo_.bar', which is a bit ugly. This patch trims leading and trailing underscores from each dot-separated key segment. Change-Id: I71172b956f5a6120a75981a15dedf372d3893b88 --- diff --git a/includes/profiler/output/ProfilerOutputStats.php b/includes/profiler/output/ProfilerOutputStats.php index ef6ef7c918..a6357935f5 100644 --- a/includes/profiler/output/ProfilerOutputStats.php +++ b/includes/profiler/output/ProfilerOutputStats.php @@ -44,6 +44,7 @@ class ProfilerOutputStats extends ProfilerOutput { $key = str_replace( '::', '.', $stat['name'] ); $key = preg_replace( '/[^a-z.]+/i', '_', $key ); $key = trim( $key, '_.' ); + $key = str_replace( array( '._', '_.' ), '.', $key ); // Convert fractional seconds to whole milliseconds $cpu = round( $stat['cpu'] * 1000 );