From dfa5dabd159f9e423ffe22ee063196a7ca09787c Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Thu, 14 May 2015 14:49:51 -0700 Subject: [PATCH] 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 --- includes/profiler/output/ProfilerOutputStats.php | 1 + 1 file changed, 1 insertion(+) 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 ); -- 2.20.1