Bug 1338812 - Call TelemetryStopwatch only once per item (history / bookmarks / logins) rather than for each resource. r?gijs
MozReview-Commit-ID: 7c5DgKDIFTv
--- a/browser/components/migration/MigrationUtils.jsm
+++ b/browser/components/migration/MigrationUtils.jsm
@@ -244,26 +244,26 @@ this.MigratorPrototype = {
if (resourceType == MigrationUtils.resourceTypes.BOOKMARKS) {
return "FX_MIGRATION_BOOKMARKS_IMPORT_MS";
}
if (resourceType == MigrationUtils.resourceTypes.PASSWORDS) {
return "FX_MIGRATION_LOGINS_IMPORT_MS";
}
return null;
};
- let maybeStartTelemetryStopwatch = (resourceType, resource) => {
+ let maybeStartTelemetryStopwatch = (resourceType) => {
let histogram = getHistogramForResourceType(resourceType);
if (histogram) {
- TelemetryStopwatch.startKeyed(histogram, this.getKey(), resource);
+ TelemetryStopwatch.startKeyed(histogram, this.getKey());
}
};
- let maybeStopTelemetryStopwatch = (resourceType, resource) => {
+ let maybeStopTelemetryStopwatch = (resourceType) => {
let histogram = getHistogramForResourceType(resourceType);
if (histogram) {
- TelemetryStopwatch.finishKeyed(histogram, this.getKey(), resource);
+ TelemetryStopwatch.finishKeyed(histogram, this.getKey());
}
};
let collectQuantityTelemetry = () => {
try {
for (let resourceType of Object.keys(MigrationUtils._importQuantities)) {
let histogramId =
"FX_MIGRATION_" + resourceType.toUpperCase() + "_QUANTITY";
@@ -292,29 +292,32 @@ this.MigratorPrototype = {
for (let resourceType of Object.keys(MigrationUtils._importQuantities)) {
MigrationUtils._importQuantities[resourceType] = 0;
}
notify("Migration:Started");
for (let [migrationType, itemResources] of resourcesGroupedByItems) {
notify("Migration:ItemBeforeMigrate", migrationType);
+ maybeStartTelemetryStopwatch(migrationType);
+
let itemSuccess = false;
for (let res of itemResources) {
- maybeStartTelemetryStopwatch(migrationType, res);
let completeDeferred = PromiseUtils.defer();
let resourceDone = function(aSuccess) {
- maybeStopTelemetryStopwatch(migrationType, res);
itemResources.delete(res);
itemSuccess |= aSuccess;
if (itemResources.size == 0) {
notify(itemSuccess ?
"Migration:ItemAfterMigrate" : "Migration:ItemError",
migrationType);
resourcesGroupedByItems.delete(migrationType);
+
+ maybeStopTelemetryStopwatch(migrationType);
+
if (resourcesGroupedByItems.size == 0) {
collectQuantityTelemetry();
notify("Migration:Ended");
}
}
completeDeferred.resolve();
};