Skip to content

RUMM-3500 View tracking gap#1578

Merged
xgouchet merged 3 commits into
developfrom
xgouchet/RUMM-3500/view_tracking_gap
Aug 22, 2023
Merged

RUMM-3500 View tracking gap#1578
xgouchet merged 3 commits into
developfrom
xgouchet/RUMM-3500/view_tracking_gap

Conversation

@xgouchet

Copy link
Copy Markdown
Contributor

What does this PR do?

Delay the view stopping event to prevent gaps between views

Motivation

A non zero gap (~100ms) exists when navigating between fragments/activities. This is because a Fragment/Activity's onResume is called some time after the previous one's onPause. This would leave a short period of time during which errors and resources would not be tracked because no Active view was available.

Additional Notes

Thoughts about additional implementation of this feature :

  • mark a view as stopped as it is, and allow adding new children events (errors, resources), until a start view is detected or only after a specific period of time.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@xgouchet
xgouchet requested a review from a team as a code owner August 16, 2023 14:16
@xgouchet
xgouchet force-pushed the xgouchet/RUMM-3500/view_tracking_gap branch from ef3a127 to 27a7901 Compare August 17, 2023 12:43

if (event is RumRawEvent.StartView && !stopped) {
startForegroundView(event, writer)
lastStoppedViewTime?.let {

@plousada plousada Aug 17, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this be triggered every time there is a gap between a stopView and startView on a manual instrumentation?
That would hinder our ability to properly assess if this gap is closed in automatic tracking strategies.

Seems like this telemetry should be moved closer to the automatic strategies so it's not influenced by manual calls to the API.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would indeed, but the tracking strategy and view scope are completely independent from one another. If we were to move this detection in the view tracking strategy itself, we'd have to duplicate the logic three times.
We do have the information of the view tracking strategy in the configuration telemetry event, meaning we can exclude orgs using manual tracking if need be to know where the gap is coming from.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.
It would be better if we could do it before sending the telemetry in the first place but detecting if we have an automated view tracking strategy in place here would create unwanted dependencies.

@xgouchet
xgouchet force-pushed the xgouchet/RUMM-3500/view_tracking_gap branch from 27a7901 to 07777fb Compare August 17, 2023 15:15
@codecov-commenter

codecov-commenter commented Aug 21, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1578 (48a80c3) into develop (1298b9e) will increase coverage by 0.08%.
Report is 3 commits behind head on develop.
The diff coverage is 95.65%.

@@             Coverage Diff             @@
##           develop    #1578      +/-   ##
===========================================
+ Coverage    83.42%   83.50%   +0.08%     
===========================================
  Files          437      437              
  Lines        14910    14945      +35     
  Branches      2230     2233       +3     
===========================================
+ Hits         12438    12479      +41     
+ Misses        1885     1877       -8     
- Partials       587      589       +2     
Files Changed Coverage Δ
...droid/rum/tracking/ActivityViewTrackingStrategy.kt 90.32% <90.91%> (+3.37%) ⬆️
...d/rum/internal/domain/scope/RumViewManagerScope.kt 96.53% <92.31%> (-0.44%) ⬇️
...nal/tracking/AndroidXFragmentLifecycleCallbacks.kt 94.44% <100.00%> (+1.59%) ⬆️
...nternal/tracking/OreoFragmentLifecycleCallbacks.kt 89.74% <100.00%> (-0.88%) ⬇️

... and 15 files with indirect coverage changes

currentFragmentExtras(activity)
)
)
// expectedEvents.add(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expected events is removed. Apparently the JUnit Runner's callActivityOnStop doesn't properly forward the fragment's onStop() to the fragment lifecycle listeners.

@xgouchet
xgouchet force-pushed the xgouchet/RUMM-3500/view_tracking_gap branch from 426e347 to 48a80c3 Compare August 21, 2023 12:33

@mariusc83 mariusc83 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xgouchet
xgouchet force-pushed the xgouchet/RUMM-3500/view_tracking_gap branch from 48a80c3 to e6890ed Compare August 21, 2023 13:28
@xgouchet
xgouchet requested a review from plousada August 21, 2023 13:28
@xgouchet
xgouchet merged commit 46a9423 into develop Aug 22, 2023
@xgouchet
xgouchet deleted the xgouchet/RUMM-3500/view_tracking_gap branch August 22, 2023 07:33
// endregion

companion object {
private const val STOP_VIEW_DELAY_MS = 200L

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this constant is defined here but also in other places. Should we unify to a SSOT incase we want to modify the delay later on?


private companion object {
private const val REPORT_FRAGMENT_NAME = "androidx.lifecycle.ReportFragment"
private const val STOP_VIEW_DELAY_MS = 200L

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous

// endregion

internal companion object {
private const val STOP_VIEW_DELAY_MS = 200L

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants