Bug 847662 - Part 1: Rename Metrics.Collector -> Metrics.ProviderManager; r=rnewman, a=bajaj
authorGregory Szorc <gps@mozilla.com>
Thu, 07 Mar 2013 05:06:46 -0800
changeset 128651 9723bf992f503af281a1ef06fa4ae5c235bda4d4
parent 128650 41e28777f3505c77e791549e44f82d401b248be5
child 128652 7fa0ed380ba95d9f18eeb7916f369e2a9880369f
push id3530
push usergszorc@mozilla.com
push dateTue, 19 Mar 2013 16:57:52 +0000
treeherdermozilla-aurora@f26e4a581008 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, bajaj
bugs847662
milestone21.0a2
Bug 847662 - Part 1: Rename Metrics.Collector -> Metrics.ProviderManager; r=rnewman, a=bajaj
services/healthreport/Makefile.in
services/healthreport/healthreporter.jsm
services/healthreport/modules-testing/utils.jsm
services/healthreport/tests/xpcshell/test_healthreporter.js
services/metrics/Makefile.in
services/metrics/Metrics.jsm
services/metrics/README.rst
services/metrics/collector.jsm
services/metrics/dataprovider.jsm
services/metrics/providermanager.jsm
services/metrics/tests/xpcshell/test_load_modules.js
services/metrics/tests/xpcshell/test_metrics_collector.js
services/metrics/tests/xpcshell/test_metrics_provider_manager.js
services/metrics/tests/xpcshell/xpcshell.ini
--- a/services/healthreport/Makefile.in
+++ b/services/healthreport/Makefile.in
@@ -21,17 +21,17 @@ testing_modules := \
 
 TEST_DIRS += tests
 
 healthreport_depends = \
   HealthReport.jsm \
   ../common/async.js \
   ../common/bagheeraclient.js \
   ../metrics/Metrics.jsm \
-  ../metrics/collector.jsm \
+  ../metrics/providermanager.jsm \
   ../metrics/dataprovider.jsm \
   ../metrics/storage.jsm \
   healthreporter.jsm \
   profile.jsm \
   providers.jsm \
   $(NULL)
 
 MAIN_JS_MODULE := HealthReport.jsm
--- a/services/healthreport/healthreporter.jsm
+++ b/services/healthreport/healthreporter.jsm
@@ -73,18 +73,18 @@ function AbstractHealthReporter(branch, 
 
   this._policy = policy;
   this.sessionRecorder = sessionRecorder;
 
   this._dbName = this._prefs.get("dbName") || DEFAULT_DATABASE_NAME;
 
   this._storage = null;
   this._storageInProgress = false;
-  this._collector = null;
-  this._collectorInProgress = false;
+  this._providerManager = null;
+  this._providerManagerInProgress = false;
   this._initialized = false;
   this._initializeHadError = false;
   this._initializedDeferred = Promise.defer();
   this._shutdownRequested = false;
   this._shutdownInitiated = false;
   this._shutdownComplete = false;
   this._shutdownCompleteCallback = null;
 
@@ -159,44 +159,44 @@ AbstractHealthReporter.prototype = Objec
     this._storage = storage;
     this._storageInProgress = false;
 
     if (this._shutdownRequested) {
       this._initiateShutdown();
       return;
     }
 
-    Task.spawn(this._initializeCollector.bind(this))
-        .then(this._onCollectorInitialized.bind(this),
+    Task.spawn(this._initializeProviderManager.bind(this))
+        .then(this._onProviderManagerInitialized.bind(this),
               this._onInitError.bind(this));
   },
 
-  _initializeCollector: function () {
+  _initializeProviderManager: function () {
     if (this._collector) {
-      throw new Error("Collector has already been initialized.");
+      throw new Error("Provider manager has already been initialized.");
     }
 
-    this._log.info("Initializing collector.");
-    this._collector = new Metrics.Collector(this._storage);
-    this._collector.onProviderError = this._recordError.bind(this);
-    this._collectorInProgress = true;
+    this._log.info("Initializing provider manager.");
+    this._providerManager = new Metrics.ProviderManager(this._storage);
+    this._providerManager.onProviderError = this._recordError.bind(this);
+    this._providerManagerInProgress = true;
 
     let catString = this._prefs.get("service.providerCategories") || "";
     if (catString.length) {
       for (let category of catString.split(",")) {
         yield this.registerProvidersFromCategoryManager(category);
       }
     }
   },
 
-  _onCollectorInitialized: function () {
+  _onProviderManagerInitialized: function () {
     TelemetryStopwatch.finish(this._initHistogram, this);
     delete this._initHistogram;
-    this._log.debug("Collector initialized.");
-    this._collectorInProgress = false;
+    this._log.debug("Provider manager initialized.");
+    this._providerManagerInProgress = false;
 
     if (this._shutdownRequested) {
       this._initiateShutdown();
       return;
     }
 
     this._log.info("HealthReporter started.");
     this._initialized = true;
@@ -265,18 +265,19 @@ AbstractHealthReporter.prototype = Objec
     this._log.info("Request to shut down.");
 
     this._initialized = false;
     this._shutdownRequested = true;
 
     if (this._initializeHadError) {
       this._log.warn("Initialization had error. Shutting down immediately.");
     } else {
-      if (this._collectorInProgress) {
-        this._log.warn("Collector is in progress of initializing. Waiting to finish.");
+      if (this._providerManagerInProcess) {
+        this._log.warn("Provider manager is in progress of initializing. " +
+                       "Waiting to finish.");
         return;
       }
 
       // If storage is in the process of initializing, we need to wait for it
       // to finish before continuing. The initialization process will call us
       // again once storage has initialized.
       if (this._storageInProgress) {
         this._log.warn("Storage is in progress of initializing. Waiting to finish.");
@@ -293,43 +294,42 @@ AbstractHealthReporter.prototype = Objec
     this._shutdownInitiated = true;
 
     // We may not have registered the observer yet. If not, this will
     // throw.
     try {
       Services.obs.removeObserver(this, "idle-daily");
     } catch (ex) { }
 
-    // If we have collectors, we need to shut down providers.
-    if (this._collector) {
-      let onShutdown = this._onCollectorShutdown.bind(this);
-      Task.spawn(this._shutdownCollector.bind(this))
+    if (this._providerManager) {
+      let onShutdown = this._onProviderManagerShutdown.bind(this);
+      Task.spawn(this._shutdownProviderManager.bind(this))
           .then(onShutdown, onShutdown);
       return;
     }
 
-    this._log.warn("Don't have collector. Proceeding to storage shutdown.");
+    this._log.warn("Don't have provider manager. Proceeding to storage shutdown.");
     this._shutdownStorage();
   },
 
-  _shutdownCollector: function () {
-    this._log.info("Shutting down collector.");
-    for (let provider of this._collector.providers) {
+  _shutdownProviderManager: function () {
+    this._log.info("Shutting down provider manager.");
+    for (let provider of this._providerManager.providers) {
       try {
         yield provider.shutdown();
       } catch (ex) {
         this._log.warn("Error when shutting down provider: " +
                        CommonUtils.exceptionStr(ex));
       }
     }
   },
 
-  _onCollectorShutdown: function () {
-    this._log.info("Collector shut down.");
-    this._collector = null;
+  _onProviderManagerShutdown: function () {
+    this._log.info("Provider manager shut down.");
+    this._providerManager = null;
     this._shutdownStorage();
   },
 
   _shutdownStorage: function () {
     if (!this._storage) {
       this._onShutdownComplete();
     }
 
@@ -421,30 +421,30 @@ AbstractHealthReporter.prototype = Objec
   /**
    * Obtain a provider from its name.
    *
    * This will only return providers that are currently initialized. If
    * a provider is lazy initialized (like pull-only providers) this
    * will likely not return anything.
    */
   getProvider: function (name) {
-    return this._collector.getProvider(name);
+    return this._providerManager.getProvider(name);
   },
 
   /**
    * Register a `Metrics.Provider` with this instance.
    *
    * This needs to be called or no data will be collected. See also
    * `registerProvidersFromCategoryManager`.
    *
    * @param provider
    *        (Metrics.Provider) The provider to register for collection.
    */
   registerProvider: function (provider) {
-    return this._collector.registerProvider(provider);
+    return this._providerManager.registerProvider(provider);
   },
 
   /**
    * Registers a provider from its constructor function.
    *
    * If the provider is pull-only, it will be stashed away and
    * initialized later. Null will be returned.
    *
@@ -573,31 +573,31 @@ AbstractHealthReporter.prototype = Objec
 
     let onFinished = function () {
       this._pullOnlyProvidersRegistered = false;
 
       return Promise.resolve();
     }.bind(this);
 
     return Task.spawn(function unregisterPullProviders() {
-      for (let provider of this._collector.providers) {
+      for (let provider of this._providerManager.providers) {
         if (!provider.pullOnly) {
           continue;
         }
 
         this._log.info("Shutting down pull-only provider: " +
                        provider.name);
 
         try {
           yield provider.shutdown();
         } catch (ex) {
           this._recordError("Error when shutting down provider: " +
                             provider.name, ex);
         } finally {
-          this._collector.unregisterProvider(provider.name);
+          this._providerManager.unregisterProvider(provider.name);
         }
       }
     }.bind(this)).then(onFinished, onFinished);
   },
 
   /**
    * Record an exception for reporting in the payload.
    *
@@ -659,17 +659,17 @@ AbstractHealthReporter.prototype = Objec
 
   /**
    * Collect all measurements for all registered providers.
    */
   collectMeasurements: function () {
     return Task.spawn(function doCollection() {
       try {
         TelemetryStopwatch.start(TELEMETRY_COLLECT_CONSTANT, this);
-        yield this._collector.collectConstantData();
+        yield this._providerManager.collectConstantData();
         TelemetryStopwatch.finish(TELEMETRY_COLLECT_CONSTANT, this);
       } catch (ex) {
         TelemetryStopwatch.cancel(TELEMETRY_COLLECT_CONSTANT, this);
         this._log.warn("Error collecting constant data: " +
                        CommonUtils.exceptionStr(ex));
       }
 
       // Daily data is collected if it hasn't yet been collected this
@@ -679,17 +679,17 @@ AbstractHealthReporter.prototype = Objec
       // makes no guarantees about limits. The alternative would involve
       // recording state. The simpler implementation prevails for now.
       if (!this._lastDailyDate ||
           Date.now() - this._lastDailyDate > MILLISECONDS_PER_DAY) {
 
         try {
           TelemetryStopwatch.start(TELEMETRY_COLLECT_DAILY, this);
           this._lastDailyDate = new Date();
-          yield this._collector.collectDailyData();
+          yield this._providerManager.collectDailyData();
           TelemetryStopwatch.finish(TELEMETRY_COLLECT_DAILY, this);
         } catch (ex) {
           TelemetryStopwatch.cancel(TELEMETRY_COLLECT_DAILY, this);
           this._log.warn("Error collecting daily data from providers: " +
                          CommonUtils.exceptionStr(ex));
         }
       }
 
@@ -783,17 +783,17 @@ AbstractHealthReporter.prototype = Objec
     let outputDataDays = o.data.days;
 
     // Guard here in case we don't track this (e.g., on Android).
     let lastPingDate = this.lastPingDate;
     if (lastPingDate && lastPingDate.getTime() > 0) {
       o.lastPingDate = this._formatDate(lastPingDate);
     }
 
-    for (let provider of this._collector.providers) {
+    for (let provider of this._providerManager.providers) {
       let providerName = provider.name;
 
       let providerEntry = {
         measurements: {},
       };
 
       for (let [measurementKey, measurement] of provider.measurements) {
         let name = providerName + "." + measurement.name;
--- a/services/healthreport/modules-testing/utils.jsm
+++ b/services/healthreport/modules-testing/utils.jsm
@@ -215,54 +215,54 @@ this.createFakeCrash = function (submitt
  * A HealthReporter that is probed with various callbacks and counters.
  *
  * The purpose of this type is to aid testing of startup and shutdown.
  */
 this.InspectedHealthReporter = function (branch, policy) {
   HealthReporter.call(this, branch, policy);
 
   this.onStorageCreated = null;
-  this.onCollectorInitialized = null;
-  this.collectorShutdownCount = 0;
+  this.onProviderManagerInitialized = null;
+  this.providerManagerShutdownCount = 0;
   this.storageCloseCount = 0;
 }
 
 InspectedHealthReporter.prototype = {
   __proto__: HealthReporter.prototype,
 
   _onStorageCreated: function (storage) {
     if (this.onStorageCreated) {
       this.onStorageCreated(storage);
     }
 
     return HealthReporter.prototype._onStorageCreated.call(this, storage);
   },
 
-  _initializeCollector: function () {
-    for (let result of HealthReporter.prototype._initializeCollector.call(this)) {
+  _initializeProviderManager: function () {
+    for (let result of HealthReporter.prototype._initializeProviderManager.call(this)) {
       yield result;
     }
 
-    if (this.onInitializeCollectorFinished) {
-      this.onInitializeCollectorFinished();
+    if (this.onInitializeProviderManagerFinished) {
+      this.onInitializeProviderManagerFinished();
     }
   },
 
-  _onCollectorInitialized: function () {
-    if (this.onCollectorInitialized) {
-      this.onCollectorInitialized();
+  _onProviderManagerInitialized: function () {
+    if (this.onProviderManagerInitialized) {
+      this.onProviderManagerInitialized();
     }
 
-    return HealthReporter.prototype._onCollectorInitialized.call(this);
+    return HealthReporter.prototype._onProviderManagerInitialized.call(this);
   },
 
-  _onCollectorShutdown: function () {
-    this.collectorShutdownCount++;
+  _onProviderManagerShutdown: function () {
+    this.providerManagerShutdownCount++;
 
-    return HealthReporter.prototype._onCollectorShutdown.call(this);
+    return HealthReporter.prototype._onProviderManagerShutdown.call(this);
   },
 
   _onStorageClose: function () {
     this.storageCloseCount++;
 
     return HealthReporter.prototype._onStorageClose.call(this);
   },
 };
--- a/services/healthreport/tests/xpcshell/test_healthreporter.js
+++ b/services/healthreport/tests/xpcshell/test_healthreporter.js
@@ -129,64 +129,66 @@ add_task(function test_shutdown_storage_
   let reporter = yield getJustReporter("shutdown_storage_in_progress", SERVER_URI, true);
 
   reporter.onStorageCreated = function () {
     print("Faking shutdown during storage initialization.");
     reporter._initiateShutdown();
   };
 
   reporter._waitForShutdown();
-  do_check_eq(reporter.collectorShutdownCount, 0);
+  do_check_eq(reporter.providerManagerShutdownCount, 0);
   do_check_eq(reporter.storageCloseCount, 1);
 });
 
-// Ensure that a shutdown triggered while collector is initializing results in
-// shutdown and storage closure.
-add_task(function test_shutdown_collector_in_progress() {
-  let reporter = yield getJustReporter("shutdown_collect_in_progress", SERVER_URI, true);
+// Ensure that a shutdown triggered while provider manager is initializing
+// results in shutdown and storage closure.
+add_task(function test_shutdown_provider_manager_in_progress() {
+  let reporter = yield getJustReporter("shutdown_provider_manager_in_progress",
+                                       SERVER_URI, true);
 
-  reporter.onCollectorInitialized = function () {
-    print("Faking shutdown during collector initialization.");
+  reporter.onProviderManagerInitialized = function () {
+    print("Faking shutdown during provider manager initialization.");
     reporter._initiateShutdown();
   };
 
   // This will hang if shutdown logic is busted.
   reporter._waitForShutdown();
-  do_check_eq(reporter.collectorShutdownCount, 1);
+  do_check_eq(reporter.providerManagerShutdownCount, 1);
   do_check_eq(reporter.storageCloseCount, 1);
 });
 
-// Simulates an error during collector initialization and verifies we shut down.
-add_task(function test_shutdown_when_collector_errors() {
-  let reporter = yield getJustReporter("shutdown_when_collector_errors", SERVER_URI, true);
+// Simulates an error during provider manager initialization and verifies we shut down.
+add_task(function test_shutdown_when_provider_manager_errors() {
+  let reporter = yield getJustReporter("shutdown_when_provider_manager_errors",
+                                       SERVER_URI, true);
 
-  reporter.onInitializeCollectorFinished = function () {
+  reporter.onInitializeProviderManagerFinished = function () {
     print("Throwing fake error.");
-    throw new Error("Fake error during collector initialization.");
+    throw new Error("Fake error during provider manager initialization.");
   };
 
   // This will hang if shutdown logic is busted.
   reporter._waitForShutdown();
-  do_check_eq(reporter.collectorShutdownCount, 1);
+  do_check_eq(reporter.providerManagerShutdownCount, 1);
   do_check_eq(reporter.storageCloseCount, 1);
 });
 
 add_task(function test_register_providers_from_category_manager() {
   const category = "healthreporter-js-modules";
 
   let cm = Cc["@mozilla.org/categorymanager;1"]
              .getService(Ci.nsICategoryManager);
   cm.addCategoryEntry(category, "DummyProvider",
                       "resource://testing-common/services/metrics/mocks.jsm",
                       false, true);
 
   let reporter = yield getReporter("category_manager");
-  do_check_eq(reporter._collector._providers.size, 0);
+  do_check_eq(reporter._providerManager._providers.size, 0);
   yield reporter.registerProvidersFromCategoryManager(category);
-  do_check_eq(reporter._collector._providers.size, 1);
+  do_check_eq(reporter._providerManager._providers.size, 1);
 
   reporter._shutdown();
 });
 
 // Pull-only providers are only initialized at collect time.
 add_task(function test_pull_only_providers() {
   const category = "healthreporter-constant-only";
 
@@ -195,29 +197,29 @@ add_task(function test_pull_only_provide
   cm.addCategoryEntry(category, "DummyProvider",
                       "resource://testing-common/services/metrics/mocks.jsm",
                       false, true);
   cm.addCategoryEntry(category, "DummyConstantProvider",
                       "resource://testing-common/services/metrics/mocks.jsm",
                       false, true);
 
   let reporter = yield getReporter("constant_only_providers");
-  do_check_eq(reporter._collector._providers.size, 0);
+  do_check_eq(reporter._providerManager._providers.size, 0);
   yield reporter.registerProvidersFromCategoryManager(category);
-  do_check_eq(reporter._collector._providers.size, 1);
+  do_check_eq(reporter._providerManager._providers.size, 1);
   do_check_true(reporter._storage.hasProvider("DummyProvider"));
   do_check_false(reporter._storage.hasProvider("DummyConstantProvider"));
   do_check_neq(reporter.getProvider("DummyProvider"), null);
   do_check_null(reporter.getProvider("DummyConstantProvider"));
 
   yield reporter.ensurePullOnlyProvidersRegistered();
   yield reporter.collectMeasurements();
   yield reporter.ensurePullOnlyProvidersUnregistered();
 
-  do_check_eq(reporter._collector._providers.size, 1);
+  do_check_eq(reporter._providerManager._providers.size, 1);
   do_check_true(reporter._storage.hasProvider("DummyConstantProvider"));
 
   let mID = reporter._storage.measurementID("DummyConstantProvider", "DummyMeasurement", 1);
   let values = yield reporter._storage.getMeasurementValues(mID);
   do_check_true(values.singular.size > 0);
 
   reporter._shutdown();
 });
@@ -328,39 +330,39 @@ add_task(function test_constant_only_pro
   let reporter = yield getReporter("constant_only_providers_in_json_payload");
   yield reporter.registerProvidersFromCategoryManager(category);
 
   let payload = yield reporter.collectAndObtainJSONPayload();
   let o = JSON.parse(payload);
   do_check_true("DummyProvider.DummyMeasurement" in o.data.last);
   do_check_true("DummyConstantProvider.DummyMeasurement" in o.data.last);
 
-  let providers = reporter._collector.providers;
+  let providers = reporter._providerManager.providers;
   do_check_eq(providers.length, 1);
 
   // Do it again for good measure.
   payload = yield reporter.collectAndObtainJSONPayload();
   o = JSON.parse(payload);
   do_check_true("DummyProvider.DummyMeasurement" in o.data.last);
   do_check_true("DummyConstantProvider.DummyMeasurement" in o.data.last);
 
-  providers = reporter._collector.providers;
+  providers = reporter._providerManager.providers;
   do_check_eq(providers.length, 1);
 
   // Ensure throwing getJSONPayload is handled properly.
   Object.defineProperty(reporter, "_getJSONPayload", {
     value: function () {
       throw new Error("Silly error.");
     },
   });
 
   let deferred = Promise.defer();
 
   reporter.collectAndObtainJSONPayload().then(do_throw, function onError() {
-    providers = reporter._collector.providers;
+    providers = reporter._providerManager.providers;
     do_check_eq(providers.length, 1);
     deferred.resolve();
   });
 
   yield deferred.promise;
 
   reporter._shutdown();
 });
--- a/services/metrics/Makefile.in
+++ b/services/metrics/Makefile.in
@@ -5,18 +5,18 @@
 DEPTH     = @DEPTH@
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 modules := \
-  collector.jsm \
   dataprovider.jsm \
+  providermanager.jsm \
   storage.jsm \
   $(NULL)
 
 testing_modules := \
   mocks.jsm \
   $(NULL)
 
 # We install Metrics.jsm into the "main" JSM repository and the rest in
@@ -32,11 +32,11 @@ JS_MODULES_PATH = $(FINAL_TARGET)/module
 PP_TARGETS += JS_MODULES
 
 TESTING_JS_MODULES := $(addprefix modules-testing/,$(testing_modules))
 TESTING_JS_MODULE_DIR := services/metrics
 
 include $(topsrcdir)/config/rules.mk
 
 # Add extra prerequisites until bug 837792 is addressed.
-$(FINAL_TARGET)/modules/Metrics.jsm: Metrics.jsm collector.jsm dataprovider.jsm storage.jsm
+$(FINAL_TARGET)/modules/Metrics.jsm: Metrics.jsm providermanager.jsm dataprovider.jsm storage.jsm
 
 
--- a/services/metrics/Metrics.jsm
+++ b/services/metrics/Metrics.jsm
@@ -14,25 +14,25 @@ const MILLISECONDS_PER_DAY = 24 * 60 * 6
 
 #endif
 
 // We concatenate the JSMs together to eliminate compartment overhead.
 // This is a giant hack until compartment overhead is no longer an
 // issue.
 #define MERGED_COMPARTMENT
 
-#include collector.jsm
+#include providermanager.jsm
 ;
 #include dataprovider.jsm
 ;
 #include storage.jsm
 ;
 
 this.Metrics = {
-  Collector: Collector,
+  ProviderManager: ProviderManager,
   DailyValues: DailyValues,
   Measurement: Measurement,
   Provider: Provider,
   Storage: MetricsStorageBackend,
   dateToDays: dateToDays,
   daysToDate: daysToDate,
 };
 
--- a/services/metrics/README.rst
+++ b/services/metrics/README.rst
@@ -31,17 +31,17 @@ Metrics.Provider
 
 Metrics.Measurement
   Represents a collection of related pieces/fields of data. Instances of
   these are essentially data structure descriptors.
 
 Metrics.Storage
   Persistent SQLite-backed store for collected metrics data and state.
 
-Metrics.Collector
+Metrics.ProviderManager
   High-level entity coordinating activity among several Metrics.Provider
   instances.
 
 SQLite Storage
 ==============
 
 *Metrics.Storage* provides an interface for persisting metrics data to a
 SQLite database.
--- a/services/metrics/dataprovider.jsm
+++ b/services/metrics/dataprovider.jsm
@@ -400,17 +400,17 @@ Measurement.prototype = Object.freeze({
  * An entity that emits data.
  *
  * A `Provider` consists of a string name (must be globally unique among all
  * known providers) and a set of `Measurement` instances.
  *
  * The main role of a `Provider` is to produce metrics data and to store said
  * data in the storage backend.
  *
- * Metrics data collection is initiated either by a collector calling a
+ * Metrics data collection is initiated either by a manager calling a
  * `collect*` function on `Provider` instances or by the `Provider` registering
  * to some external event and then reacting whenever they occur.
  *
  * `Provider` implementations interface directly with a storage backend. For
  * common stored values (daily counters, daily discrete values, etc),
  * implementations should interface with storage via the various helper
  * functions on the `Measurement` instances. For custom stored value types,
  * implementations will interact directly with the low-level storage APIs.
rename from services/metrics/collector.jsm
rename to services/metrics/providermanager.jsm
--- a/services/metrics/collector.jsm
+++ b/services/metrics/providermanager.jsm
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 #ifndef MERGED_COMPARTMENT
-this.EXPORTED_SYMBOLS = ["Collector"];
+this.EXPORTED_SYMBOLS = ["ProviderManager"];
 
 const {utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/services/metrics/dataprovider.jsm");
 #endif
 
 Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
 Cu.import("resource://gre/modules/Task.jsm");
@@ -19,27 +19,27 @@ Cu.import("resource://services-common/ut
 
 
 /**
  * Handles and coordinates the collection of metrics data from providers.
  *
  * This provides an interface for managing `Metrics.Provider` instances. It
  * provides APIs for bulk collection of data.
  */
-this.Collector = function (storage) {
-  this._log = Log4Moz.repository.getLogger("Services.Metrics.Collector");
+this.ProviderManager = function (storage) {
+  this._log = Log4Moz.repository.getLogger("Services.Metrics.ProviderManager");
 
   this._providers = new Map();
   this._storage = storage;
 
   this._providerInitQueue = [];
   this._providerInitializing = false;
 }
 
-Collector.prototype = Object.freeze({
+this.ProviderManager.prototype = Object.freeze({
   get providers() {
     let providers = [];
     for (let [name, entry] of this._providers) {
       providers.push(entry.provider);
     }
 
     return providers;
   },
@@ -53,17 +53,17 @@ Collector.prototype = Object.freeze({
     if (!provider) {
       return null;
     }
 
     return provider.provider;
   },
 
   /**
-   * Registers a `MetricsProvider` with this collector.
+   * Registers a `MetricsProvider` with this manager.
    *
    * Once a `MetricsProvider` is registered, data will be collected from it
    * whenever we collect data.
    *
    * The returned value is a promise that will be resolved once registration
    * is complete.
    *
    * Providers are initialized as part of registration by calling
@@ -89,17 +89,17 @@ Collector.prototype = Object.freeze({
     if (this._providerInitQueue.length == 1) {
       this._popAndInitProvider();
     }
 
     return deferred.promise;
   },
 
   /**
-   * Remove a named provider from the collector.
+   * Remove a named provider from the manager.
    *
    * It is the caller's responsibility to shut down the provider
    * instance.
    */
   unregisterProvider: function (name) {
     this._providers.delete(name);
   },
 
@@ -134,18 +134,18 @@ Collector.prototype = Object.freeze({
     }.bind(this));
   },
 
   /**
    * Collects all constant measurements from all providers.
    *
    * Returns a Promise that will be fulfilled once all data providers have
    * provided their constant data. A side-effect of this promise fulfillment
-   * is that the collector is populated with the obtained collection results.
-   * The resolved value to the promise is this `Collector` instance.
+   * is that the manager is populated with the obtained collection results.
+   * The resolved value to the promise is this `ProviderManager` instance.
    */
   collectConstantData: function () {
     let entries = [];
 
     for (let [name, entry] of this._providers) {
       if (entry.constantsCollected) {
         this._log.trace("Provider has already provided constant data: " +
                         name);
--- a/services/metrics/tests/xpcshell/test_load_modules.js
+++ b/services/metrics/tests/xpcshell/test_load_modules.js
@@ -1,16 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const modules = [
-  "collector.jsm",
   "dataprovider.jsm",
+  "providermanager.jsm",
   "storage.jsm",
 ];
 
 const test_modules = [
   "mocks.jsm",
 ];
 
 function run_test() {
rename from services/metrics/tests/xpcshell/test_metrics_collector.js
rename to services/metrics/tests/xpcshell/test_metrics_provider_manager.js
--- a/services/metrics/tests/xpcshell/test_metrics_collector.js
+++ b/services/metrics/tests/xpcshell/test_metrics_provider_manager.js
@@ -9,149 +9,149 @@ Cu.import("resource://gre/modules/Metric
 Cu.import("resource://testing-common/services/metrics/mocks.jsm");
 
 function run_test() {
   run_next_test();
 };
 
 add_task(function test_constructor() {
   let storage = yield Metrics.Storage("constructor");
-  let collector = new Metrics.Collector(storage);
+  let manager = new Metrics.ProviderManager(storage);
 
   yield storage.close();
 });
 
 add_task(function test_register_provider() {
   let storage = yield Metrics.Storage("register_provider");
 
-  let collector = new Metrics.Collector(storage);
+  let manager = new Metrics.ProviderManager(storage);
   let dummy = new DummyProvider();
 
-  yield collector.registerProvider(dummy);
-  do_check_eq(collector._providers.size, 1);
-  yield collector.registerProvider(dummy);
-  do_check_eq(collector._providers.size, 1);
-  do_check_eq(collector.getProvider(dummy.name), dummy);
+  yield manager.registerProvider(dummy);
+  do_check_eq(manager._providers.size, 1);
+  yield manager.registerProvider(dummy);
+  do_check_eq(manager._providers.size, 1);
+  do_check_eq(manager.getProvider(dummy.name), dummy);
 
   let failed = false;
   try {
-    collector.registerProvider({});
+    manager.registerProvider({});
   } catch (ex) {
     do_check_true(ex.message.startsWith("Argument must be a Provider"));
     failed = true;
   } finally {
     do_check_true(failed);
     failed = false;
   }
 
-  collector.unregisterProvider(dummy.name);
-  do_check_eq(collector._providers.size, 0);
-  do_check_null(collector.getProvider(dummy.name));
+  manager.unregisterProvider(dummy.name);
+  do_check_eq(manager._providers.size, 0);
+  do_check_null(manager.getProvider(dummy.name));
 
   yield storage.close();
 });
 
 add_task(function test_collect_constant_data() {
   let storage = yield Metrics.Storage("collect_constant_data");
   let errorCount = 0;
-  let collector = new Metrics.Collector(storage);
-  collector.onProviderError = function () { errorCount++; }
+  let manager= new Metrics.ProviderManager(storage);
+  manager.onProviderError = function () { errorCount++; }
   let provider = new DummyProvider();
-  yield collector.registerProvider(provider);
+  yield manager.registerProvider(provider);
 
   do_check_eq(provider.collectConstantCount, 0);
 
-  yield collector.collectConstantData();
+  yield manager.collectConstantData();
   do_check_eq(provider.collectConstantCount, 1);
 
-  do_check_true(collector._providers.get("DummyProvider").constantsCollected);
+  do_check_true(manager._providers.get("DummyProvider").constantsCollected);
 
   yield storage.close();
   do_check_eq(errorCount, 0);
 });
 
 add_task(function test_collect_constant_throws() {
   let storage = yield Metrics.Storage("collect_constant_throws");
-  let collector = new Metrics.Collector(storage);
+  let manager = new Metrics.ProviderManager(storage);
   let errors = [];
-  collector.onProviderError = function (error) { errors.push(error); };
+  manager.onProviderError = function (error) { errors.push(error); };
 
   let provider = new DummyProvider();
   provider.throwDuringCollectConstantData = "Fake error during collect";
-  yield collector.registerProvider(provider);
+  yield manager.registerProvider(provider);
 
-  yield collector.collectConstantData();
+  yield manager.collectConstantData();
   do_check_eq(errors.length, 1);
   do_check_true(errors[0].contains(provider.throwDuringCollectConstantData));
 
   yield storage.close();
 });
 
 add_task(function test_collect_constant_populate_throws() {
   let storage = yield Metrics.Storage("collect_constant_populate_throws");
-  let collector = new Metrics.Collector(storage);
+  let manager = new Metrics.ProviderManager(storage);
   let errors = [];
-  collector.onProviderError = function (error) { errors.push(error); };
+  manager.onProviderError = function (error) { errors.push(error); };
 
   let provider = new DummyProvider();
   provider.throwDuringConstantPopulate = "Fake error during constant populate";
-  yield collector.registerProvider(provider);
+  yield manager.registerProvider(provider);
 
-  yield collector.collectConstantData();
+  yield manager.collectConstantData();
 
   do_check_eq(errors.length, 1);
   do_check_true(errors[0].contains(provider.throwDuringConstantPopulate));
-  do_check_false(collector._providers.get(provider.name).constantsCollected);
+  do_check_false(manager._providers.get(provider.name).constantsCollected);
 
   yield storage.close();
 });
 
 add_task(function test_collect_constant_onetime() {
   let storage = yield Metrics.Storage("collect_constant_onetime");
-  let collector = new Metrics.Collector(storage);
+  let manager = new Metrics.ProviderManager(storage);
   let provider = new DummyProvider();
-  yield collector.registerProvider(provider);
+  yield manager.registerProvider(provider);
 
-  yield collector.collectConstantData();
+  yield manager.collectConstantData();
   do_check_eq(provider.collectConstantCount, 1);
 
-  yield collector.collectConstantData();
+  yield manager.collectConstantData();
   do_check_eq(provider.collectConstantCount, 1);
 
   yield storage.close();
 });
 
 add_task(function test_collect_multiple() {
   let storage = yield Metrics.Storage("collect_multiple");
-  let collector = new Metrics.Collector(storage);
+  let manager = new Metrics.ProviderManager(storage);
 
   for (let i = 0; i < 10; i++) {
-    yield collector.registerProvider(new DummyProvider("provider" + i));
+    yield manager.registerProvider(new DummyProvider("provider" + i));
   }
 
-  do_check_eq(collector._providers.size, 10);
+  do_check_eq(manager._providers.size, 10);
 
-  yield collector.collectConstantData();
+  yield manager.collectConstantData();
 
   yield storage.close();
 });
 
 add_task(function test_collect_daily() {
   let storage = yield Metrics.Storage("collect_daily");
-  let collector = new Metrics.Collector(storage);
+  let manager = new Metrics.ProviderManager(storage);
 
   let provider1 = new DummyProvider("DP1");
   let provider2 = new DummyProvider("DP2");
 
-  yield collector.registerProvider(provider1);
-  yield collector.registerProvider(provider2);
+  yield manager.registerProvider(provider1);
+  yield manager.registerProvider(provider2);
 
-  yield collector.collectDailyData();
+  yield manager.collectDailyData();
   do_check_eq(provider1.collectDailyCount, 1);
   do_check_eq(provider2.collectDailyCount, 1);
 
-  yield collector.collectDailyData();
+  yield manager.collectDailyData();
   do_check_eq(provider1.collectDailyCount, 2);
   do_check_eq(provider2.collectDailyCount, 2);
 
   yield storage.close();
 });
 
--- a/services/metrics/tests/xpcshell/xpcshell.ini
+++ b/services/metrics/tests/xpcshell/xpcshell.ini
@@ -1,8 +1,8 @@
 [DEFAULT]
 head = head.js
 tail =
 
 [test_load_modules.js]
 [test_metrics_provider.js]
-[test_metrics_collector.js]
+[test_metrics_provider_manager.js]
 [test_metrics_storage.js]