Commit 93ad23f3 authored by Grisha Kruglov's avatar Grisha Kruglov
Browse files

Closes #6196: Add 'total duration' metric to all migrations

parent 6e1631e4
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -24,35 +24,41 @@ The following metrics are added to the ping:
| migration.addons.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.addons.migrated_addons |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |How many addons were migrated?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.addons.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.addons.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.bookmarks.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.bookmarks.detected |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Total number of detected bookmarks prior to a migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.bookmarks.duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Duration of the bookmarks migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.bookmarks.duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Duration of the bookmarks migration (Rust operations).  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.bookmarks.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.bookmarks.migrated |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Counters describing how bookmark migration went; should add-up to 'migration.bookmarks.detected'.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)|<ul><li>succeeded</li><li>failed</li></ul>|2020-10-01 |
| migration.bookmarks.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.bookmarks.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.fxa.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.fxa.bad_auth_state |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |If we couldn't migrate due to a bad auth state, what was it?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.fxa.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.fxa.has_custom_idp_server |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Is custom idp server configured?  |[1](https://github.com/mozilla-mobile/android-components/pull/5582#issuecomment-574673110)||2020-10-01 |
| migration.fxa.has_custom_token_server |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Is custom token server configured?  |[1](https://github.com/mozilla-mobile/android-components/pull/5582#issuecomment-574673110)||2020-10-01 |
| migration.fxa.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.fxa.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.fxa.unsupported_account_version |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |What is the detected unsupported account version?  |[1](https://github.com/mozilla-mobile/android-components/pull/5582#issuecomment-574673110)||2020-10-01 |
| migration.fxa.unsupported_pickle_version |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |What is the detected unsupported pickle version?  |[1](https://github.com/mozilla-mobile/android-components/pull/5582#issuecomment-574673110)||2020-10-01 |
| migration.fxa.unsupported_state_version |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |What is the detected unsupported state version?  |[1](https://github.com/mozilla-mobile/android-components/pull/5582#issuecomment-574673110)||2020-10-01 |
| migration.gecko.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.gecko.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.gecko.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.gecko.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.history.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.history.detected |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Total number of detected history items prior to a migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.history.duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Duration of the history migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.history.duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Duration of the history migration (Rust operations).  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.history.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.history.migrated |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Counters describing how history migration went; should add-up to 'migration.history.detected'.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)|<ul><li>succeeded</li><li>failed</li></ul>|2020-10-01 |
| migration.history.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.history.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.logins.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.logins.detected |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |How many logins were detected?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.logins.failure_counts |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |How many logins failed to be migrated, and in which ways?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)|<ul><li>process</li><li>import</li></ul>|2020-10-01 |
| migration.logins.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.logins.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.logins.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.logins.unsupported_db_version |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |If we couldn't migrate due to an unsupported db version, what was it?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.migration_versions |[labeled_string](https://mozilla.github.io/glean/book/user/metrics/labeled_strings.html) |Versions of the migrations which were executed.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)|<ul><li>history</li><li>bookmarks</li><li>logins</li><li>open_tabs</li><li>fxa</li><li>gecko</li><li>settings</li><li>telemetry_identifiers</li><li>addons</li><li>search</li><li>pinned_sites</li></ul>|2020-10-01 |
| migration.open_tabs.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
@@ -60,23 +66,28 @@ The following metrics are added to the ping:
| migration.open_tabs.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.open_tabs.migrated |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Number of migrated open tabs.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.open_tabs.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.pinned_sites.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](TODO)||2020-10-01 |
| migration.pinned_sites.detected_pinned_sites |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |How many pinned sites were detected?  |[1](TODO)||2020-10-01 |
| migration.pinned_sites.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](TODO)||2020-10-01 |
| migration.pinned_sites.migrated_pinned_sites |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |How many pinned sites were migrated?  |[1](TODO)||2020-10-01 |
| migration.pinned_sites.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](TODO)||2020-10-01 |
| migration.open_tabs.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.pinned_sites.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.pinned_sites.detected_pinned_sites |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |How many pinned sites were detected?  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.pinned_sites.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.pinned_sites.migrated_pinned_sites |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |How many pinned sites were migrated?  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.pinned_sites.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.pinned_sites.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.search.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/5819#pullrequestreview-353890362)||2020-10-01 |
| migration.search.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5819#pullrequestreview-353890362)||2020-10-01 |
| migration.search.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5819#pullrequestreview-353890362)||2020-10-01 |
| migration.search.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.settings.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.settings.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.settings.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.settings.telemetry_enabled |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Is telemetry enabled after this migration?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.settings.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |
| migration.telemetry_identifiers.any_failures |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Did this migration encounter any failures (exceptions)?  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.telemetry_identifiers.failure_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration failed. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.telemetry_identifiers.fennec_client_id |[uuid](https://mozilla.github.io/glean/book/user/metrics/uuid.html) |Records clientID of the migrated Fennec profile.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.telemetry_identifiers.fennec_profile_creation_date |[datetime](https://mozilla.github.io/glean/book/user/metrics/datetime.html) |Records when the migrated Fennec profile was created.  |[1](https://github.com/mozilla-mobile/android-components/pull/5483#issuecomment-573971458)||2020-10-01 |
| migration.telemetry_identifiers.success_reason |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |Why this migration succeeded. See codes in TelemetryHelpers.kt  |[1](https://github.com/mozilla-mobile/android-components/pull/5655#pullrequestreview-346359792)||2020-10-01 |
| migration.telemetry_identifiers.total_duration |[timespan](https://mozilla.github.io/glean/book/user/metrics/timespan.html) |Total duration of this migration.  |[1](https://github.com/mozilla-mobile/android-components/pull/6214#pullrequestreview-372237195)||2020-10-01 |


<!-- AUTOGENERATED BY glean_parser.  DO NOT EDIT. -->
+172 −7

File changed.

Preview size limit exceeded, changes collapsed.

+5 −15
Original line number Diff line number Diff line
@@ -585,6 +585,8 @@ class FennecMigrator private constructor(
            val migrationVersion = versionedMigration.version
            MigrationPing.migrationVersions[telemetryId].set("$migrationVersion")

            versionedMigration.migration.metricTotalDuration().start()

            val migrationResult = when (versionedMigration.migration) {
                Migration.History -> migrateHistory()
                Migration.Bookmarks -> migrateBookmarks()
@@ -599,28 +601,16 @@ class FennecMigrator private constructor(
                Migration.PinnedSites -> migratePinnedSites()
            }

            versionedMigration.migration.metricTotalDuration().stop()

            val migrationRun = when (migrationResult) {
                is Result.Failure<*> -> {
                    logger.error(
                        "Failed to migrate $versionedMigration",
                        migrationResult.throwables.first()
                    )
                    // Local fun to make `when` exhaustive.
                    fun setFailure(migration: Migration): Unit = when (migration) {
                        Migration.History -> MigrationHistory.anyFailures.set(true)
                        Migration.Bookmarks -> MigrationBookmarks.anyFailures.set(true)
                        Migration.OpenTabs -> MigrationOpenTabs.anyFailures.set(true)
                        Migration.FxA -> MigrationFxa.anyFailures.set(true)
                        Migration.Gecko -> MigrationGecko.anyFailures.set(true)
                        Migration.Logins -> MigrationLogins.anyFailures.set(true)
                        Migration.Settings -> MigrationSettings.anyFailures.set(true)
                        Migration.Addons -> MigrationAddons.anyFailures.set(true)
                        Migration.TelemetryIdentifiers -> MigrationTelemetryIdentifiers.anyFailures.set(true)
                        Migration.SearchEngine -> MigrationSearch.anyFailures.set(true)
                        Migration.PinnedSites -> MigrationPinnedSites.anyFailures.set(true)
                    }
                    setFailure(versionedMigration.migration)

                    versionedMigration.migration.metricAnyFailures().set(true)
                    MigrationRun(versionedMigration.version, false)
                }
                is Result.Success<*> -> {
+40 −0
Original line number Diff line number Diff line
@@ -4,6 +4,18 @@

package mozilla.components.support.migration

import mozilla.components.support.migration.GleanMetrics.MigrationAddons
import mozilla.components.support.migration.GleanMetrics.MigrationBookmarks
import mozilla.components.support.migration.GleanMetrics.MigrationFxa
import mozilla.components.support.migration.GleanMetrics.MigrationGecko
import mozilla.components.support.migration.GleanMetrics.MigrationHistory
import mozilla.components.support.migration.GleanMetrics.MigrationLogins
import mozilla.components.support.migration.GleanMetrics.MigrationOpenTabs
import mozilla.components.support.migration.GleanMetrics.MigrationPinnedSites
import mozilla.components.support.migration.GleanMetrics.MigrationSearch
import mozilla.components.support.migration.GleanMetrics.MigrationSettings
import mozilla.components.support.migration.GleanMetrics.MigrationTelemetryIdentifiers

// Must match labels of the migration_versions metric.
internal fun Migration.telemetryIdentifier(): String {
    return when (this) {
@@ -21,6 +33,34 @@ internal fun Migration.telemetryIdentifier(): String {
    }
}

internal fun Migration.metricTotalDuration() = when (this) {
    Migration.History -> MigrationHistory.totalDuration
    Migration.Bookmarks -> MigrationBookmarks.totalDuration
    Migration.OpenTabs -> MigrationOpenTabs.totalDuration
    Migration.FxA -> MigrationFxa.totalDuration
    Migration.Gecko -> MigrationGecko.totalDuration
    Migration.Logins -> MigrationLogins.totalDuration
    Migration.Settings -> MigrationSettings.totalDuration
    Migration.Addons -> MigrationAddons.totalDuration
    Migration.TelemetryIdentifiers -> MigrationTelemetryIdentifiers.totalDuration
    Migration.SearchEngine -> MigrationSearch.totalDuration
    Migration.PinnedSites -> MigrationPinnedSites.totalDuration
}

internal fun Migration.metricAnyFailures() = when (this) {
    Migration.History -> MigrationHistory.anyFailures
    Migration.Bookmarks -> MigrationBookmarks.anyFailures
    Migration.OpenTabs -> MigrationOpenTabs.anyFailures
    Migration.FxA -> MigrationFxa.anyFailures
    Migration.Gecko -> MigrationGecko.anyFailures
    Migration.Logins -> MigrationLogins.anyFailures
    Migration.Settings -> MigrationSettings.anyFailures
    Migration.Addons -> MigrationAddons.anyFailures
    Migration.TelemetryIdentifiers -> MigrationTelemetryIdentifiers.anyFailures
    Migration.SearchEngine -> MigrationSearch.anyFailures
    Migration.PinnedSites -> MigrationPinnedSites.anyFailures
}

// Failure/success codes are used in the migration ping, to avoid sending strings.
// Append any extra errors at the end with a unique, sequential (to make it easy to spot dupes) 'code'.
@SuppressWarnings("MagicNumber")