зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1308337 - Part 4: Instrument FetchMetaGlobal stage r=nalexander
MozReview-Commit-ID: 6zXqgsAIajN --HG-- extra : rebase_source : c4a10afafe83bbb404ad47a56b7c5c389c716dd6
This commit is contained in:
Родитель
c4c33eaf1b
Коммит
627c7eaf6d
|
@ -295,6 +295,10 @@ public class GlobalSession implements HttpResponseObserver {
|
|||
|
||||
// For named stages, use the repository name.
|
||||
String collectorName = currentState.getRepositoryName();
|
||||
// For unnamed, non-repository stages use name of the stage itself.
|
||||
if (collectorName == null) {
|
||||
collectorName = currentState.name();
|
||||
}
|
||||
final TelemetryStageCollector stageCollector = telemetryCollector.collectorFor(collectorName);
|
||||
// Stage is responsible for setting the 'finished' timestamp when appropriate.
|
||||
stageCollector.started = SystemClock.elapsedRealtime();
|
||||
|
@ -659,12 +663,13 @@ public class GlobalSession implements HttpResponseObserver {
|
|||
/*
|
||||
* meta/global callbacks.
|
||||
*/
|
||||
public void processMetaGlobal(MetaGlobal global) {
|
||||
public void processMetaGlobal(MetaGlobal global, TelemetryStageCollector stageCollector) {
|
||||
config.metaGlobal = global;
|
||||
|
||||
Long storageVersion = global.getStorageVersion();
|
||||
if (storageVersion == null) {
|
||||
Logger.warn(LOG_TAG, "Malformed remote meta/global: could not retrieve remote storage version.");
|
||||
stageCollector.error = new TelemetryCollector.StageErrorBuilder("metaglobal", "noversion").build();
|
||||
freshStart();
|
||||
return;
|
||||
}
|
||||
|
@ -685,6 +690,7 @@ public class GlobalSession implements HttpResponseObserver {
|
|||
String remoteSyncID = global.getSyncID();
|
||||
if (remoteSyncID == null) {
|
||||
Logger.warn(LOG_TAG, "Malformed remote meta/global: could not retrieve remote syncID.");
|
||||
stageCollector.error = new TelemetryCollector.StageErrorBuilder("metaglobal", "nosyncid").build();
|
||||
freshStart();
|
||||
return;
|
||||
}
|
||||
|
@ -1131,7 +1137,7 @@ public class GlobalSession implements HttpResponseObserver {
|
|||
public void requiresUpgrade() {
|
||||
Logger.info(LOG_TAG, "Client outdated storage version; requires update.");
|
||||
// TODO: notify UI.
|
||||
this.abort(null, "Requires upgrade");
|
||||
this.abort(null, "Requires upgrade from " + STORAGE_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,18 +4,26 @@
|
|||
|
||||
package org.mozilla.gecko.sync.stage;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import org.mozilla.gecko.background.common.log.Logger;
|
||||
import org.mozilla.gecko.sync.GlobalSession;
|
||||
import org.mozilla.gecko.sync.HTTPFailureException;
|
||||
import org.mozilla.gecko.sync.InfoCollections;
|
||||
import org.mozilla.gecko.sync.MetaGlobal;
|
||||
import org.mozilla.gecko.sync.PersistedMetaGlobal;
|
||||
import org.mozilla.gecko.sync.delegates.MetaGlobalDelegate;
|
||||
import org.mozilla.gecko.sync.net.SyncStorageResponse;
|
||||
import org.mozilla.gecko.sync.telemetry.TelemetryCollector;
|
||||
|
||||
public class FetchMetaGlobalStage extends AbstractNonRepositorySyncStage {
|
||||
private static final String LOG_TAG = "FetchMetaGlobalStage";
|
||||
private static final String META_COLLECTION = "meta";
|
||||
|
||||
private static final String TELEMETRY_ERROR_NAME = "metaglobal";
|
||||
private static final String TELEMETRY_ERROR_MISSING = "missing";
|
||||
private static final String TELEMETRY_ERROR_NO_INFO_COLLECTIONS = "noic";
|
||||
|
||||
public class StageMetaGlobalDelegate implements MetaGlobalDelegate {
|
||||
|
||||
private final GlobalSession session;
|
||||
|
@ -31,21 +39,34 @@ public class FetchMetaGlobalStage extends AbstractNonRepositorySyncStage {
|
|||
// Take the timestamp from the response since it is later than the timestamp from info/collections.
|
||||
pmg.persistLastModified(response.normalizedWeaveTimestamp());
|
||||
|
||||
session.processMetaGlobal(global);
|
||||
telemetryStageCollector.finished = SystemClock.elapsedRealtime();
|
||||
session.processMetaGlobal(global, telemetryStageCollector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleFailure(SyncStorageResponse response) {
|
||||
telemetryStageCollector.error = new TelemetryCollector.StageErrorBuilder()
|
||||
.setLastException(new HTTPFailureException(response))
|
||||
.build();
|
||||
telemetryStageCollector.finished = SystemClock.elapsedRealtime();
|
||||
session.handleHTTPError(response, "Failure fetching meta/global.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleError(Exception e) {
|
||||
telemetryStageCollector.error = new TelemetryCollector.StageErrorBuilder()
|
||||
.setLastException(e)
|
||||
.build();
|
||||
telemetryStageCollector.finished = SystemClock.elapsedRealtime();
|
||||
session.abort(e, "Failure fetching meta/global.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMissing(MetaGlobal global, SyncStorageResponse response) {
|
||||
// While not strictly an error, it's good to keep track of this.
|
||||
telemetryStageCollector.error = new TelemetryCollector
|
||||
.StageErrorBuilder(TELEMETRY_ERROR_NAME, TELEMETRY_ERROR_MISSING)
|
||||
.build();
|
||||
session.processMissingMetaGlobal(global);
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +75,10 @@ public class FetchMetaGlobalStage extends AbstractNonRepositorySyncStage {
|
|||
public void execute() throws NoSuchStageException {
|
||||
InfoCollections infoCollections = session.config.infoCollections;
|
||||
if (infoCollections == null) {
|
||||
telemetryStageCollector.finished = SystemClock.elapsedRealtime();
|
||||
telemetryStageCollector.error = new TelemetryCollector
|
||||
.StageErrorBuilder(TELEMETRY_ERROR_NAME, TELEMETRY_ERROR_NO_INFO_COLLECTIONS)
|
||||
.build();
|
||||
session.abort(null, "No info/collections set in FetchMetaGlobalStage.");
|
||||
return;
|
||||
}
|
||||
|
@ -65,7 +90,8 @@ public class FetchMetaGlobalStage extends AbstractNonRepositorySyncStage {
|
|||
MetaGlobal global = session.config.persistedMetaGlobal().metaGlobal(session.config.metaURL(), session.getAuthHeaderProvider());
|
||||
if (global != null) {
|
||||
Logger.info(LOG_TAG, "Using persisted meta/global for this session.");
|
||||
session.processMetaGlobal(global); // Calls session.advance().
|
||||
telemetryStageCollector.finished = SystemClock.elapsedRealtime();
|
||||
session.processMetaGlobal(global, telemetryStageCollector); // Calls session.advance().
|
||||
return;
|
||||
}
|
||||
Logger.info(LOG_TAG, "Failed to use persisted meta/global for this session.");
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
package org.mozilla.gecko.sync.stage;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
|
@ -68,7 +70,7 @@ public interface GlobalSyncStage {
|
|||
|
||||
// Each Stage tracks its repositoryName.
|
||||
private final String repositoryName;
|
||||
public String getRepositoryName() {
|
||||
@Nullable public String getRepositoryName() {
|
||||
return repositoryName;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче