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

RUMM-1061: Add a warning when RUM action is dropped while another action is still active for the same view #503

Conversation

0xnm
Copy link
Contributor

@0xnm 0xnm commented Feb 23, 2021

What does this PR do?

Additional help to investigate #490

Motivation

Issue #490

Additional Notes

N/A

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)

@0xnm 0xnm requested a review from a team as a code owner February 23, 2021 13:24
@@ -158,7 +159,15 @@ internal class RumViewScope(
) {
delegateEventToChildren(event, writer)

if (stopped || activeActionScope != null) return
if (stopped) return
Copy link
Contributor Author

@0xnm 0xnm Feb 23, 2021

Choose a reason for hiding this comment

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

no logging (even verbose) in this case to be consistent with other onXXX methods in this class (probably it can happen quite often?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes it can happen too often that the previous view is still present but stopped.

Copy link
Collaborator

@xgouchet xgouchet left a comment

Choose a reason for hiding this comment

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

Good work 👍

Can you add a test about it? You can look at the M log warning W handleEvent() without child scope test in the RumSessionScopeTest class to see how you can test the devLogger

@@ -158,7 +159,15 @@ internal class RumViewScope(
) {
delegateEventToChildren(event, writer)

if (stopped || activeActionScope != null) return
if (stopped) return
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes it can happen too often that the previous view is still present but stopped.

@0xnm
Copy link
Contributor Author

0xnm commented Feb 23, 2021

Good work 👍

Can you add a test about it? You can look at the M log warning W handleEvent() without child scope test in the RumSessionScopeTest class to see how you can test the devLogger

thanks @xgouchet . this is the part I was missing, I was looking for the examples of validating i, w, etc. calls in the tests. now with handleLog validation example it is clear.

@0xnm 0xnm force-pushed the nogorodnikov/rumm-1061/add-warning-when-rum-action-is-dropped-while-another-is-active branch from d2741f5 to 4257658 Compare February 23, 2021 15:36
@0xnm 0xnm requested a review from xgouchet February 23, 2021 15:37
verify(mockDevLogHandler).handleLog(
eq(Log.WARN),
argThat {
contains("was dropped") &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't go for the exact match on purpose

Copy link
Collaborator

Choose a reason for hiding this comment

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

why not asserting the whole string here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because then I have to copy-paste it here (it is parametrized) and keep both in sync, but not a big deal if needed. Just imo we care about the context of the message only.

Copy link
Collaborator

Choose a reason for hiding this comment

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

if you use an internal constant for that message format in the other class then you can share it with the test. This is what we usually do in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, but the thing is that it is not constant, it is parametrized. I saw that in some places there is dedicated format method to format message with parameters. do you propose to extract it to the format method?

Copy link
Collaborator

@mariusc83 mariusc83 Feb 23, 2021

Choose a reason for hiding this comment

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

Exactly ;) this is what I usually do, but it is not dedicated method is the String default method. Basically you can write:

companion object {
 internal const val WARNING_ERROR_MESSAGE_FORMAT="RUM Action (%s on %s) was dropped, because another action is still active for the same view"
}

and then use it like:

  WARNING_ERROR_MESSAGE.format(eventType,eventName)

verify(mockDevLogHandler).handleLog(
eq(Log.WARN),
argThat {
contains("was dropped") &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not asserting the whole string here ?

@codecov-io
Copy link

Codecov Report

Merging #503 (11d99c3) into master (59b0700) will increase coverage by 0.15%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master     #503      +/-   ##
============================================
+ Coverage     89.12%   89.27%   +0.15%     
- Complexity     1409     1413       +4     
============================================
  Files           168      168              
  Lines          4928     4931       +3     
  Branches        569      570       +1     
============================================
+ Hits           4392     4402      +10     
+ Misses          345      339       -6     
+ Partials        191      190       -1     
Impacted Files Coverage Δ Complexity Δ
.../android/rum/internal/domain/scope/RumViewScope.kt 95.14% <100.00%> (+0.06%) 71.00 <0.00> (ø)
...internal/tracking/JetpackViewAttributesProvider.kt 73.68% <0.00%> (-15.79%) 8.00% <0.00%> (-1.00%)
...nal/tracking/AndroidXFragmentLifecycleCallbacks.kt 87.80% <0.00%> (-4.88%) 13.00% <0.00%> (-1.00%)
.../android/tracing/internal/domain/SpanSerializer.kt 86.75% <0.00%> (-1.20%) 21.00% <0.00%> (-1.00%)
...c/main/kotlin/com/datadog/android/DatadogConfig.kt 94.92% <0.00%> (+1.02%) 12.00% <0.00%> (+2.00%)
...l/net/info/BroadcastReceiverNetworkInfoProvider.kt 79.38% <0.00%> (+1.03%) 29.00% <0.00%> (+1.00%)
...oid/src/main/kotlin/com/datadog/android/Datadog.kt 88.16% <0.00%> (+1.32%) 31.00% <0.00%> (+1.00%)
...tadog/android/log/internal/domain/LogSerializer.kt 91.89% <0.00%> (+1.35%) 29.00% <0.00%> (ø%)
...ernal/instrumentation/gestures/GesturesListener.kt 91.45% <0.00%> (+1.71%) 46.00% <0.00%> (+1.00%)
...g/android/rum/internal/domain/scope/RumEventExt.kt 81.82% <0.00%> (+1.82%) 0.00% <0.00%> (ø%)
... and 2 more

@0xnm 0xnm merged commit 70688f3 into master Feb 24, 2021
@0xnm 0xnm deleted the nogorodnikov/rumm-1061/add-warning-when-rum-action-is-dropped-while-another-is-active branch February 24, 2021 08:53
@xgouchet xgouchet added this to the 1.9.0 milestone May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants