From d37529e416802e145b054db7dfd478e793d35572 Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Wed, 13 May 2020 14:10:23 -0700 Subject: [PATCH] Perf telemetry for awesomebar suggestion provider durations See mozilla-mobile/android-components#6802 for details; requires that PR. --- app/metrics.yaml | 107 ++++++++++++++++++ .../fenix/components/metrics/Metrics.kt | 28 +++++ docs/metrics.md | 7 ++ 3 files changed, 142 insertions(+) diff --git a/app/metrics.yaml b/app/metrics.yaml index db8620783..23e9bbe18 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -2179,3 +2179,110 @@ startup.timeline: - perf-android-fe@mozilla.com - mcomella@mozilla.com expires: "2020-07-15" + +perf.awesomebar: + history_suggestions: + send_in_pings: + - metrics + type: timing_distribution + time_unit: millisecond + description: > + Duration of a history awesomebar suggestion query. + bugs: + - https://github.com/mozilla-mobile/android-components/issues/4992 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979 + notification_emails: + - fenix-core@mozilla.com + - gkruglov@mozilla.com + expires: "2020-09-15" + bookmark_suggestions: + send_in_pings: + - metrics + type: timing_distribution + time_unit: millisecond + description: > + Duration of a bookmarks awesomebar suggestion query. + bugs: + - https://github.com/mozilla-mobile/android-components/issues/4992 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979 + notification_emails: + - fenix-core@mozilla.com + - gkruglov@mozilla.com + expires: "2020-09-15" + search_engine_suggestions: + send_in_pings: + - metrics + type: timing_distribution + time_unit: millisecond + description: > + Duration of a search engine awesomebar suggestion query. + bugs: + - https://github.com/mozilla-mobile/android-components/issues/4992 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979 + notification_emails: + - fenix-core@mozilla.com + - gkruglov@mozilla.com + expires: "2020-09-15" + session_suggestions: + send_in_pings: + - metrics + type: timing_distribution + time_unit: millisecond + description: > + Duration of a session awesomebar suggestion query. + bugs: + - https://github.com/mozilla-mobile/android-components/issues/4992 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979 + notification_emails: + - fenix-core@mozilla.com + - gkruglov@mozilla.com + expires: "2020-09-15" + synced_tabs_suggestions: + send_in_pings: + - metrics + type: timing_distribution + time_unit: millisecond + description: > + Duration of a synced tabs awesomebar suggestion query. + bugs: + - https://github.com/mozilla-mobile/android-components/issues/4992 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979 + notification_emails: + - fenix-core@mozilla.com + - gkruglov@mozilla.com + expires: "2020-09-15" + clipboard_suggestions: + send_in_pings: + - metrics + type: timing_distribution + time_unit: millisecond + description: > + Duration of a clipboard awesomebar suggestion query. + bugs: + - https://github.com/mozilla-mobile/android-components/issues/4992 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979 + notification_emails: + - fenix-core@mozilla.com + - gkruglov@mozilla.com + expires: "2020-09-15" + shortcuts_suggestions: + send_in_pings: + - metrics + type: timing_distribution + time_unit: millisecond + description: > + Duration of a shortcuts awesomebar suggestion query. + bugs: + - https://github.com/mozilla-mobile/android-components/issues/4992 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979 + notification_emails: + - fenix-core@mozilla.com + - gkruglov@mozilla.com + expires: "2020-09-15" diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt index a52ed27bb..875a9e736 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt @@ -5,10 +5,17 @@ package org.mozilla.fenix.components.metrics import android.content.Context +import mozilla.components.browser.awesomebar.facts.BrowserAwesomeBarFacts import mozilla.components.browser.errorpages.ErrorType import mozilla.components.browser.menu.facts.BrowserMenuFacts import mozilla.components.browser.search.SearchEngine import mozilla.components.browser.toolbar.facts.ToolbarFacts +import mozilla.components.concept.awesomebar.AwesomeBar +import mozilla.components.feature.awesomebar.provider.BookmarksStorageSuggestionProvider +import mozilla.components.feature.awesomebar.provider.ClipboardSuggestionProvider +import mozilla.components.feature.awesomebar.provider.SearchSuggestionProvider +import mozilla.components.feature.awesomebar.provider.SessionSuggestionProvider +import mozilla.components.feature.awesomebar.provider.HistoryStorageSuggestionProvider import mozilla.components.feature.contextmenu.facts.ContextMenuFacts import mozilla.components.feature.customtabs.CustomTabsFacts import mozilla.components.feature.downloads.facts.DownloadsFacts @@ -30,11 +37,13 @@ import org.mozilla.fenix.GleanMetrics.CrashReporter import org.mozilla.fenix.GleanMetrics.ErrorPage import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Logins +import org.mozilla.fenix.GleanMetrics.PerfAwesomebar import org.mozilla.fenix.GleanMetrics.SearchShortcuts import org.mozilla.fenix.GleanMetrics.Tip import org.mozilla.fenix.GleanMetrics.ToolbarSettings import org.mozilla.fenix.GleanMetrics.TrackingProtection import org.mozilla.fenix.R +import org.mozilla.fenix.search.awesomebar.ShortcutsSuggestionProvider import java.util.Locale sealed class Event { @@ -471,6 +480,25 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) { null } + Component.BROWSER_AWESOMEBAR to BrowserAwesomeBarFacts.Items.PROVIDER_DURATION -> { + metadata?.get(BrowserAwesomeBarFacts.MetadataKeys.DURATION_PAIR)?.let { providerTiming -> + require(providerTiming is Pair<*, *>) { "Expected providerTiming to be a Pair" } + when (val provider = providerTiming.first as AwesomeBar.SuggestionProvider) { + is HistoryStorageSuggestionProvider -> PerfAwesomebar.historySuggestions + is BookmarksStorageSuggestionProvider -> PerfAwesomebar.bookmarkSuggestions + is SessionSuggestionProvider -> PerfAwesomebar.sessionSuggestions + is SearchSuggestionProvider -> PerfAwesomebar.searchEngineSuggestions + is ClipboardSuggestionProvider -> PerfAwesomebar.clipboardSuggestions + is ShortcutsSuggestionProvider -> PerfAwesomebar.shortcutsSuggestions + // NB: add PerfAwesomebar.syncedTabsSuggestions once we're using SyncedTabsSuggestionProvider + else -> { + Logger("Metrics").error("Unknown suggestion provider: $provider") + null + } + }?.accumulateSamples(longArrayOf(providerTiming.second as Long)) + } + null + } else -> null } diff --git a/docs/metrics.md b/docs/metrics.md index 6a2b2ca7b..e008d2b34 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -233,6 +233,13 @@ The following metrics are added to the ping: | metrics.search_count |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |The labels for this counter are `.`. If the search engine is bundled with Fenix `search-engine-name` will be the name of the search engine. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be `custom`. `source` will be: `action`, `suggestion`, `widget` or `shortcut` (depending on the source from which the search started). Also added the `other` option for the source but it should never enter on this case. |[1](https://github.com/mozilla-mobile/fenix/pull/1677), [2](https://github.com/mozilla-mobile/fenix/pull/5216), [3](https://github.com/mozilla-mobile/fenix/pull/7310)||2020-09-01 | | metrics.toolbar_position |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string that indicates the new position of the toolbar TOP or BOTTOM |[1](https://github.com/mozilla-mobile/fenix/pull/6608)||2020-09-01 | | metrics.top_sites_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A counter that indicates how many top sites a user has |[1](https://github.com/mozilla-mobile/fenix/pull/9556)||2020-09-01 | +| perf.awesomebar.bookmark_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a bookmarks awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | +| perf.awesomebar.clipboard_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a clipboard awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | +| perf.awesomebar.history_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a history awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | +| perf.awesomebar.search_engine_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a search engine awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | +| perf.awesomebar.session_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a session awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | +| perf.awesomebar.shortcuts_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a shortcuts awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | +| perf.awesomebar.synced_tabs_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a synced tabs awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | | search.default_engine.code |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |If the search engine is pre-loaded with Fenix this value will be the search engine identifier. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be "custom" |[1](https://github.com/mozilla-mobile/fenix/pull/1606), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-09-01 | | search.default_engine.name |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |If the search engine is pre-loaded with Fenix this value will be the search engine name. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be "custom" |[1](https://github.com/mozilla-mobile/fenix/pull/1606), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-09-01 | | search.default_engine.submission_url |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |If the search engine is pre-loaded with Fenix this value will be he base URL we use to build the search query for the search engine. For example: https://mysearchengine.com/?query=%s. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be "custom" |[1](https://github.com/mozilla-mobile/fenix/pull/1606), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-09-01 |