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
$key = str_replace( '::', '.', $stat['name'] );
$key = preg_replace( '/[^a-z.]+/i', '_', $key );
$key = trim( $key, '_.' );
$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 );
// Convert fractional seconds to whole milliseconds
$cpu = round( $stat['cpu'] * 1000 );