Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1570647 - Do not send 'metrics' ping if the app was not used #3993

Merged
merged 1 commit into from Aug 5, 2019

Conversation

@travis79
Copy link
Member

travis79 commented Aug 1, 2019

This attempts to address the issue around sending of metrics pings when the app hasn't been used for that day.

Pull Request checklist

  • Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry or does not need one
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features

After merge

  • Milestone: Make sure issues closed by this pull request are added to the milestone of the version currently in development.
@travis79 travis79 requested a review from mozilla-mobile/telemetry as a code owner Aug 1, 2019
@travis79 travis79 requested review from Dexterp37 and mdboom Aug 1, 2019
@travis79

This comment has been minimized.

Copy link
Member Author

travis79 commented Aug 1, 2019

This is silly but the test I added (startupCheck happens when returning from background when Glean is already initialized) runs perfect in debug but fails in release, so any ideas on why that might be would be greatly appreciated.

@travis79 travis79 force-pushed the travis79:mps-fix branch 2 times, most recently from 981ae04 to e7fc7b9 Aug 1, 2019
@mdboom
mdboom approved these changes Aug 1, 2019
Copy link
Contributor

mdboom left a comment

Looks good. Just one additional thing to test, if possible.

// If this is the first ON_START event since the app was launched, Glean wouldn't be
// initialized yet.
if (Glean.isInitialized()) {
Glean.metricsPingScheduler.startupCheck()

This comment has been minimized.

Copy link
@mdboom

mdboom Aug 1, 2019

Contributor

The risk of this change might be that when it enters foreground multiple times during the same 24 hour period, the ping is scheduled for sending twice (at the same 4AM instant the next morning). I think the fact that we use WorkManager.getInstance().enqueueUniqueWork() makes that impossible, but I wonder if there's a way to write a test for that.

This comment has been minimized.

Copy link
@travis79

travis79 Aug 2, 2019

Author Member

I could also check to see if a Worker is already enqueued, which I didn't really think to do either. I agree we should be okay since we do use the enqueueUniqueWork but a test and/or a check wouldn't hurt.

This comment has been minimized.

Copy link
@Dexterp37

Dexterp37 Aug 2, 2019

Contributor

One test could be to use the workmanager testing api to enqueue two unique work units and check if both are there. But that would only test the WorkManager API, and I bet that such a test is already there, for them

// If this is the first ON_START event since the app was launched, Glean wouldn't be
// initialized yet.
if (Glean.isInitialized()) {
Glean.metricsPingScheduler.startupCheck()

This comment has been minimized.

Copy link
@Dexterp37

Dexterp37 Aug 2, 2019

Contributor

One test could be to use the workmanager testing api to enqueue two unique work units and check if both are there. But that would only test the WorkManager API, and I bet that such a test is already there, for them

@travis79 travis79 force-pushed the travis79:mps-fix branch 2 times, most recently from e47bf4d to af0d5ce Aug 2, 2019
@travis79 travis79 force-pushed the travis79:mps-fix branch 4 times, most recently from 68bc886 to 50556c4 Aug 5, 2019
@travis79 travis79 requested a review from Dexterp37 Aug 5, 2019
Copy link
Contributor

Dexterp37 left a comment

This looks good to me. When porting this to glean-core, we should document the new specifications (we don't send if we were not in foreground in the measurement window).

Let's get a review from Sebastian and Mike as well. Please also take this for a manual test drive.

@Dexterp37 Dexterp37 requested review from mdboom and pocmo Aug 5, 2019
@travis79

This comment has been minimized.

Copy link
Member Author

travis79 commented Aug 5, 2019

This looks good to me. When porting this to glean-core, we should document the new specifications (we don't send if we were not in foreground in the measurement window).

Let's get a review from Sebastian and Mike as well. Please also take this for a manual test drive.

Sounds good to me, working on the manual test drive today and looks like you already flagged @mdboom and @pocmo

@mdboom
mdboom approved these changes Aug 5, 2019
Copy link
Contributor

mdboom left a comment

LGTM

@travis79 travis79 force-pushed the travis79:mps-fix branch 3 times, most recently from c235333 to a51d300 Aug 5, 2019
Also removes unnecessary type arguments from MetricsPingSchedulerTest.kt
@travis79 travis79 force-pushed the travis79:mps-fix branch from a51d300 to 0492a92 Aug 5, 2019
@codecov

This comment has been minimized.

Copy link

codecov bot commented Aug 5, 2019

Codecov Report

Merging #3993 into master will decrease coverage by 2.49%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #3993     +/-   ##
===========================================
- Coverage     82.55%   80.05%   -2.5%     
+ Complexity     3660     3360    -300     
===========================================
  Files           481      450     -31     
  Lines         15686    14826    -860     
  Branches       2347     2221    -126     
===========================================
- Hits          12949    11869   -1080     
- Misses         1758     2038    +280     
+ Partials        979      919     -60
Impacted Files Coverage Δ Complexity Δ
...ponents/service/experiments/ExperimentEvaluator.kt 85.57% <0%> (-0.97%) 57% <0%> (-1%)
...ts/service/glean/storages/CountersStorageEngine.kt
...s/service/glean/storages/DatetimesStorageEngine.kt
...omponents/service/glean/private/EventMetricType.kt
...ts/service/glean/storages/BooleansStorageEngine.kt
...s/service/glean/storages/TimespansStorageEngine.kt
...vice/glean/private/TimingDistributionMetricType.kt
...service/glean/storages/ExperimentsStorageEngine.kt
...illa/components/browser/storage/sync/Connection.kt
...components/service/glean/private/UuidMetricType.kt
... and 52 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3e5bc2...0492a92. Read the comment docs.

@travis79 travis79 merged commit 54a0a58 into mozilla-mobile:master Aug 5, 2019
1 check passed
1 check passed
Taskcluster (pull_request) TaskGroup: success
Details
@travis79 travis79 deleted the travis79:mps-fix branch Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.