Skip to content

RUM-2503 Use internal key for View Scopes#1812

Merged
xgouchet merged 4 commits into
developfrom
xgouchet/RUM-2503/rum_key
Jan 12, 2024
Merged

RUM-2503 Use internal key for View Scopes#1812
xgouchet merged 4 commits into
developfrom
xgouchet/RUM-2503/rum_key

Conversation

@xgouchet

@xgouchet xgouchet commented Jan 8, 2024

Copy link
Copy Markdown
Contributor

What does this PR do?

Use an Internal Key representation instead of a (weak) reference to actual customer instances.

Motivation

Prevent leaking memory with UI related instances (Activity, Fragment, …)

@xgouchet
xgouchet requested review from a team as code owners January 8, 2024 10:44

@0xnm 0xnm 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.

Nice work! I left few questions.

internal data class RumScopeKey(
val id: String,
val url: String,
val name: String?

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.

It seems that this property is not used?

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.

Missed an additional commit

is FragmentNavigator.Destination -> key.className

else -> key.javaClass.name
}

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.

Minor: since the logic for resolveName and resolveUrl are the same, we could consolidate this by extracting the when to a third method - wdyt? Do we expect them to differ in future?

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.

They could be different in the future indeed

@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.

Nice work, same concerns as @0xnm regarding the url resolver.

@xgouchet
xgouchet requested review from 0xnm and mariusc83 January 10, 2024 11:00
@xgouchet
xgouchet requested a review from 0xnm January 10, 2024 14:22

@0xnm 0xnm 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! I've added one minor thought.

val childScope = iterator.next()
if (event is RumRawEvent.StopView) {
if (childScope.isActive() && (childScope as? RumViewScope)?.keyRef?.get() == event.key) {
if (childScope.isActive() && (childScope as? RumViewScope)?.key?.id == event.key.id) {

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.

In order to make sure that we check id property in the test and not the whole key, maybe we can modify the tests for this class (and for RumViewScope) to use different RumScopeKey for different calls (same ID, but different name/url), but it is not a blocker for me, more like something useful to add.

@xgouchet
xgouchet force-pushed the xgouchet/RUM-2503/rum_key branch 4 times, most recently from cecac6d to 7672da1 Compare January 11, 2024 17:25
@xgouchet
xgouchet force-pushed the xgouchet/RUM-2503/rum_key branch from 7672da1 to 04d4a93 Compare January 12, 2024 07:50
@codecov-commenter

codecov-commenter commented Jan 12, 2024

Copy link
Copy Markdown

Codecov Report

Merging #1812 (04d4a93) into develop (723fbc8) will increase coverage by 0.02%.
The diff coverage is 90.41%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1812      +/-   ##
===========================================
+ Coverage    83.47%   83.49%   +0.02%     
===========================================
  Files          466      467       +1     
  Lines        16360    16412      +52     
  Branches      2456     2482      +26     
===========================================
+ Hits         13656    13702      +46     
- Misses        2025     2032       +7     
+ Partials       679      678       -1     
Files Coverage Δ
...d/rum/internal/domain/scope/RumApplicationScope.kt 94.57% <100.00%> (+4.67%) ⬆️
...g/android/rum/internal/domain/scope/RumRawEvent.kt 100.00% <100.00%> (ø)
...um/internal/domain/scope/RumViewChangedListener.kt 100.00% <100.00%> (ø)
.../android/rum/internal/domain/scope/RumViewScope.kt 93.31% <100.00%> (+0.25%) ⬆️
.../android/rum/internal/monitor/DatadogRumMonitor.kt 84.10% <100.00%> (-0.71%) ⬇️
...d/rum/internal/domain/scope/RumViewManagerScope.kt 96.99% <90.00%> (+0.07%) ⬆️
...g/android/rum/internal/domain/scope/RumScopeKey.kt 86.67% <86.67%> (ø)

... and 22 files with indirect coverage changes

@xgouchet
xgouchet merged commit cf5bce1 into develop Jan 12, 2024
@xgouchet
xgouchet deleted the xgouchet/RUM-2503/rum_key branch January 12, 2024 08:15
@xgouchet xgouchet added this to the 2.5.0 milestone Feb 19, 2024
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