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

RUM-1930 Add regression test for Gson toString method #1742

Merged

Conversation

mariusc83
Copy link
Member

@mariusc83 mariusc83 commented Nov 22, 2023

What does this PR do?

As a followup on the previous action taken on iOS: https://datadoghq.atlassian.net/browse/RUM-1929, I investigated all the potential issues on our end regarding this topic and came to the following conclusions:

  • we are using indeed . attributes on our end but most of them are correctly handled in our serializers.
  • it will be quite hard and very intrusive to try to remove all these attributes in the sdk and for no reason momentarily because the serializers are handling this. There is only one problem that could appear if by any chance we adopt a new Gson version which changes the implementation in adding the properties into the toString method. Right now they are using a LinkedList which suites us very well.

In this PR I added a regression test for our Gson dependency to make sure it will always add the properties in the order they were added in the Json object when using the toString method.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

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)

@mariusc83 mariusc83 self-assigned this Nov 22, 2023
@mariusc83 mariusc83 force-pushed the mconstantin/rum-1930/remove-dot-attributest-in-events branch from 4212a4a to b7da33f Compare November 23, 2023 07:40
@mariusc83 mariusc83 changed the title RUM-1930 Sanitize internal dot keys in the LogEvent generator RUM-1930 Add regression test for Gson toString method Nov 23, 2023
@mariusc83 mariusc83 marked this pull request as ready for review November 23, 2023 07:43
@mariusc83 mariusc83 requested review from a team as code owners November 23, 2023 07:43
fun `M add the properties in order in the string W toString()`(forge:Forge){
val propertiesKeysValues = forge.aMap(size = forge.anInt(min=5,max=50)){
val key = forge.aList(size = forge.anInt(min = 1, max = 10)) {
anAlphabeticalString() }.joinToString(".")
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to have dots in keys? We simply test that keys are added in order, we don't care about keys format.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes but I wanted to just make sure it is robust enough. It doesn't hurt to have the dots there.

* `toString` representation in the order they were added in the JSON object.
*/

@Extensions(ExtendWith(ForgeExtension::class), )
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Extensions(ExtendWith(ForgeExtension::class), )
@Extensions(ExtendWith(ForgeExtension::class))

@mariusc83 mariusc83 force-pushed the mconstantin/rum-1930/remove-dot-attributest-in-events branch from b7da33f to 3324639 Compare November 23, 2023 08:28
@codecov-commenter
Copy link

codecov-commenter commented Nov 23, 2023

Codecov Report

Merging #1742 (e5e7b69) into develop (1b499cf) will decrease coverage by 0.27%.
Report is 12 commits behind head on develop.
The diff coverage is n/a.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1742      +/-   ##
===========================================
- Coverage    83.58%   83.31%   -0.27%     
===========================================
  Files          465      465              
  Lines        16182    16182              
  Branches      2412     2412              
===========================================
- Hits         13525    13482      -43     
- Misses        2016     2039      +23     
- Partials       641      661      +20     

see 22 files with indirect coverage changes

Copy link
Member

@jonathanmos jonathanmos left a comment

Choose a reason for hiding this comment

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

lgtm - one minor comment

append("{")
propertiesKeysValues.entries.forEachIndexed { index, entry ->
when (entry.value) {
is Int -> append("\"${entry.key}\":${entry.value}")
Copy link
Member

Choose a reason for hiding this comment

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

Since Int and Boolean look like they have the same logic, would it make sense to do

Suggested change
is Int -> append("\"${entry.key}\":${entry.value}")
is Int, is Boolean -> append("\"${entry.key}\":${entry.value}")

to avoid duplication?

@mariusc83 mariusc83 force-pushed the mconstantin/rum-1930/remove-dot-attributest-in-events branch from 3324639 to e5e7b69 Compare November 23, 2023 09:24
@mariusc83 mariusc83 merged commit a2b2c39 into develop Nov 23, 2023
5 checks passed
@mariusc83 mariusc83 deleted the mconstantin/rum-1930/remove-dot-attributest-in-events branch November 23, 2023 09:57
@xgouchet xgouchet added this to the 2.4.0 milestone Dec 13, 2023
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