Skip to content

RUMM-1121 use sensible defaults in Configuration#521

Merged
xgouchet merged 5 commits into
masterfrom
xgouchet/RUMM-1121/configuration_defaults
Mar 10, 2021
Merged

RUMM-1121 use sensible defaults in Configuration#521
xgouchet merged 5 commits into
masterfrom
xgouchet/RUMM-1121/configuration_defaults

Conversation

@xgouchet

@xgouchet xgouchet commented Mar 9, 2021

Copy link
Copy Markdown
Contributor

What does this PR do?

Use sensible defaults in RUM Configuration

Motivation

The goal is to make the onboarding quick and easy for new customers with sensible defaults that should:

  • work out of the box
  • provide relevant events (event if it's not perfect for every case).
    This means that we set the default ViewTrackingStrategy to track activity (all Android apps will have at least one activity); long tasks are tracked with a default threshold of 100ms (>6 times the threshold for a 60 FPS target) and tracking actions with the default tracker.

@xgouchet xgouchet self-assigned this Mar 9, 2021
@xgouchet
xgouchet requested a review from a team as a code owner March 9, 2021 18:25
@xgouchet xgouchet added the size-medium This PR is medium sized label Mar 9, 2021

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

looks good!

return true
}

override fun hashCode(): Int {

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.

is there a reason why other classes of this PR have javaClass.hashCode() as body of that method, and this class takes a different approach?

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 think the reason why is that there's no other field in those classes to based your hashcode function on.

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.

As Marius said, only classes with no field use the javaClass.hashCode() value. When a class has fields (participating in the equals implementation), the same fields need to participate to the hashCode implementation by contract.

}

override fun hashCode(): Int {
return thresholdMs.hashCode()

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.

why only this field participates in the hashcode calculation?

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.

It's because the thresholdNS is derived from thresholdMs so it would be redundant by design, and the startUptimeNs and target are transient property that don't change the strategy's configuration.


// region Object

override fun equals(other: Any?): Boolean {

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.

why do you need to change the default implementation here ?

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.

Because the default equals implementation simply compares the objects address.


// region Object

override fun equals(other: Any?): Boolean {

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 would really advise to properly test all these re-implementations of equals/hashcode methods ?

other as ActivityViewTrackingStrategy

if (trackExtras != other.trackExtras) return false
if (componentPredicate != other.componentPredicate) return false

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.

here you want to compare by value or by reference ? I think it should be by reference (!==)

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.

No I want to compare by value

return true
}

override fun hashCode(): Int {

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 think the reason why is that there's no other field in those classes to based your hashcode function on.

@xgouchet
xgouchet force-pushed the xgouchet/RUMM-1121/configuration_defaults branch from d8f73b6 to 4dc3fa4 Compare March 10, 2021 10:10
keepStartingWith("com.android.internal.util.")
keepStartingWith("android.util.")
keep("android.content.ComponentName")
keep("android.os.Looper")

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.

Why do you need this ?

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.

Because the tests are using the Loopers.

@xgouchet
xgouchet force-pushed the xgouchet/RUMM-1121/configuration_defaults branch from 4dc3fa4 to ff4430c Compare March 10, 2021 16:11
@xgouchet xgouchet added the size-large This PR is large sized label Mar 10, 2021
@xgouchet
xgouchet requested a review from mariusc83 March 10, 2021 16:11
*/
@Suppress("ReplaceCallWithBinaryOperator", "StringLiteralDuplication")
@ExtendWith(ForgeExtension::class)
abstract class ObjectTest<T : Any> {

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.

tks !!

// When
repeat(64) {
val y = createUnequalInstance(x, forge)
if (y != null && y !== x) {

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.

why do you need this comparison ? Can the createUnequalInstace function return the same instance ?

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.

Because createUnequalInstance is implemented by a child class, I just wanted to be safe.

@xgouchet
xgouchet merged commit 17b9fb2 into master Mar 10, 2021
@xgouchet
xgouchet deleted the xgouchet/RUMM-1121/configuration_defaults branch March 10, 2021 17:56
@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

Labels

size-large This PR is large sized size-medium This PR is medium sized

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants