Added controlling mechanisms for the metrics collection code, so that it can be enabled or disabled on a per-service basis.