Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Adding loading time and immersive mode duration Glean telemetry.
Browse files Browse the repository at this point in the history
  • Loading branch information
daoshengmu committed May 27, 2020
1 parent ebe5512 commit 423851d
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 12 deletions.
246 changes: 246 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,249 @@ control:
- [email protected]
- [email protected]
expires: "2020-11-01"

pages:
page_load:
type: timing_distribution
description: >
Measuring how long each page takes to load.
time_unit: nanosecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"

immersive:
duration:
type: timing_distribution
description: >
Measuring how long users stay in the immersive mode.
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"

windows:
duration:
type: timing_distribution
description: >
Measuring how long windows keep opening.
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
movement:
type: counter
description: >
Counting how many times of moving a window in a session.
send_in_pings:
- session-end
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
resize:
type: counter
description: >
Counting how many times of resizing a window in a session.
send_in_pings:
- session-end
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
active_in_left_time:
type: timing_distribution
description: >
Measuring how long a window is placed at the left in a session.
send_in_pings:
- session-end
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
active_in_right_time:
type: timing_distribution
description: >
Measuring how long a window is placed at the right in a session.
send_in_pings:
- session-end
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
active_in_front_time:
type: timing_distribution
description: >
Measuring how long a window is placed at the front in a session.
send_in_pings:
- session-end
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
single_window_opened_time:
type: timing_distribution
description: >
Measuring how long a user uses single window in a session.
send_in_pings:
- session-end
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
double_window_opened_time:
type: timing_distribution
description: >
Measuring how long a user uses double windows in a session.
send_in_pings:
- session-end
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
triple_window_opened_time:
type: timing_distribution
description: >
Measuring how long a user uses triple window in a session.
send_in_pings:
- session-end
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
single_pri_window_opened_time:
type: timing_distribution
description: >
Measuring how long a user uses single private window in a session.
send_in_pings:
- session-end
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
double_pri_window_opened_time:
type: timing_distribution
description: >
Measuring how long a user uses double private windows in a session.
send_in_pings:
- session-end
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
triple_pri_window_opened_time:
type: timing_distribution
description: >
Measuring how long a user uses triple private windows in a session.
send_in_pings:
- session-end
time_unit: microsecond
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2279
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
opened_window_count:
type: labeled_counter
description: >
Counting which multiple window mode (single, double, triple)
user are using in a session.
send_in_pings:
- session-end
labels:
- single
- double
- triple
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2230
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
opened_pri_window_count:
type: labeled_counter
description: >
Counting which multiple private window mode (single, double, triple)
user are using in a session.
send_in_pings:
- session-end
labels:
- single
- double
- triple
bugs:
- https://github.com/MozillaReality/FirefoxReality/issues/2230
data_reviews:
- https://github.com/MozillaReality/FirefoxReality/pull/xxx
notification_emails:
- [email protected]
- [email protected]
expires: "2020-11-01"
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ public void onPageStart(@NonNull GeckoSession aSession, @NonNull String aUri) {
Log.d(LOGTAG, "Session onPageStart");
mState.mIsLoading = true;
TelemetryWrapper.startPageLoadTime();
GleanMetricsService.startPageLoadTime();
GleanMetricsService.startPageLoadTime(aUri);

setWebXRState(SessionState.WEBXR_UNUSED);
for (GeckoSession.ProgressDelegate listener : mProgressListeners) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.mozilla.vrbrowser.GleanMetrics.Searches;
import org.mozilla.vrbrowser.GleanMetrics.Url;
import org.mozilla.vrbrowser.GleanMetrics.Control;
import org.mozilla.vrbrowser.GleanMetrics.Pages;
import org.mozilla.vrbrowser.GleanMetrics.Immersive;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.search.SearchEngineWrapper;
import org.mozilla.vrbrowser.utils.DeviceType;
Expand All @@ -36,6 +38,8 @@ public class GleanMetricsService {
private static boolean initialized = false;
private static Context context = null;
private static HashSet<String> domainMap = new HashSet<String>();
private static Map<String, GleanTimerId> loadingTimerId = new Hashtable<>();
private static GleanTimerId immersiveTimerId;

// We should call this at the application initial stage.
public static void init(Context aContext) {
Expand Down Expand Up @@ -68,14 +72,19 @@ public static void stop() {
Glean.INSTANCE.setUploadEnabled(false);
}

public static void startPageLoadTime() {
// TODO: Blocked by Bug 1595914.
// pageLoadingTimerId = Pages.INSTANCE.getPageLoad().start();
public static void startPageLoadTime(String aUrl) {
GleanTimerId pageLoadingTimerId = Pages.INSTANCE.pageLoad().start();
loadingTimerId.put(aUrl, pageLoadingTimerId);
}

public static void stopPageLoadTimeWithURI(String uri) {
// TODO: Blocked by Bug 1595914.
// Pages.INSTANCE.getPageLoad().stopAndAccumulate(pageLoadingTimerId);
if (loadingTimerId.containsKey(uri)) {
GleanTimerId pageLoadingTimerId = loadingTimerId.get(uri);
Pages.INSTANCE.pageLoad().stopAndAccumulate(pageLoadingTimerId);
loadingTimerId.remove(uri);
} else {
Log.e(LOGTAG, "Can't find page loading url.");
}

try {
URI uriLink = URI.create(uri);
Expand All @@ -87,7 +96,6 @@ public static void stopPageLoadTimeWithURI(String uri) {
Url.INSTANCE.domains().add();
}
Url.INSTANCE.visits().add();

} catch (IllegalArgumentException e) {
Log.e(LOGTAG, "Invalid URL", e);
}
Expand All @@ -96,7 +104,8 @@ public static void stopPageLoadTimeWithURI(String uri) {

public static void sessionStop() {
domainMap.clear();
Pings.INSTANCE.sessionEnd().send();
loadingTimerId.clear();
Pings.INSTANCE.sessionEnd().submit();
}

@UiThread
Expand All @@ -121,13 +130,11 @@ public static void voiceInputEvent() {
}

public static void startImmersive() {
// TODO: Blocked by Bug 1595914 and 1595723.
// immersiveTimerId = Durarion.INSTANCE.getImmersiveMode().start();
immersiveTimerId = Immersive.INSTANCE.duration().start();
}

public static void stopImmersive() {
// TODO: Blocked by Bug 1595914 and 1595723.
// Durarion.INSTANCE.getImmersiveMode().stopAndAccumulate(immersiveTimerId);
Immersive.INSTANCE.duration().stopAndAccumulate(immersiveTimerId);
}

// TODO: Confirm if we don't need multiple metrics for tracking window open duration.
Expand Down
2 changes: 2 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ The following metrics are added to the ping:
| firefox_account.history_sync_status |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |History sync engine status. True means that the history sync status is enabled, false otherwise. |[1](https://github.com/MozillaReality/FirefoxReality/pull/2327#issuecomment-559103837), [2](https://github.com/MozillaReality/FirefoxReality/pull/3199#issuecomment-617938749)||2020-11-01 |
| firefox_account.received_tab |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Number of received tabs per day |[1](https://github.com/MozillaReality/FirefoxReality/pull/2327#issuecomment-559103837), [2](https://github.com/MozillaReality/FirefoxReality/pull/3199#issuecomment-617938749)|<ul><li>desktop</li><li>mobile</li><li>tablet</li><li>tv</li><li>vr</li><li>unknown</li></ul>|2020-11-01 |
| firefox_account.tab_sent |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Number of tabs successfully sent per day |[1](https://github.com/MozillaReality/FirefoxReality/pull/2327#issuecomment-559103837), [2](https://github.com/MozillaReality/FirefoxReality/pull/3199#issuecomment-617938749)||2020-11-01 |
| immersive.duration |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Measuring how long users stay in the immersive mode. |[1](https://github.com/MozillaReality/FirefoxReality/pull/xxx)||2020-11-01 |
| pages.page_load |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Measuring how long each page takes to load. |[1](https://github.com/MozillaReality/FirefoxReality/pull/xxx)||2020-11-01 |
| searches.counts |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Counting how many searches are queried in a specific search engine. The search engine `identifier`s are used as keys for this metric. |[1](https://github.com/MozillaReality/FirefoxReality/pull/2241#issuecomment-557740258), [2](https://github.com/MozillaReality/FirefoxReality/pull/3199#issuecomment-617938749)||2020-11-01 |
| url.query_type |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Counting how many URLs are visited in a day, by input method. |[1](https://github.com/MozillaReality/FirefoxReality/pull/2241#issuecomment-557740258), [2](https://github.com/MozillaReality/FirefoxReality/pull/3199#issuecomment-617938749)|<ul><li>type_link</li><li>type_query</li><li>voice_query</li></ul>|2020-11-01 |

Expand Down

0 comments on commit 423851d

Please sign in to comment.