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-5778] Custom Vitals Collection V3 #2929

Merged
merged 13 commits into from
Aug 28, 2024

Conversation

nulrich
Copy link
Contributor

@nulrich nulrich commented Aug 8, 2024

Motivation

We would like to be able to report concurrent vitals with the same name and allowing better visualisations. And for better flexibility, we also want to be able to use global vitals.

Changes

Update custom vital structure:

The custom vital value is now in duration field instead of in custom object.

Update custom vital API:

startDurationVital/stopDurationVital can be used to:

  • global vitals

To track performance accros components.

startDurationVital('myGlobalVital')
stopDurationVital('myGlobalVital')
  • parallels vitals

To track performance of multiple instance the same components.

const ref = startDurationVital('myComponentVital')
stopDurationVital(ref)

Also introducing addDurationVital to create a vital with a custom duration and startVital values.

All those methods now have a description attribute that can be used to differentiate vitals using the same name.

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 88.63636% with 5 lines in your changes missing coverage. Please review.

Project coverage is 93.43%. Comparing base (670d5ce) to head (b14e8cf).
Report is 4 commits behind head on main.

Files Patch % Lines
packages/rum-core/src/boot/rumPublicApi.ts 58.33% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2929      +/-   ##
==========================================
- Coverage   93.47%   93.43%   -0.04%     
==========================================
  Files         271      271              
  Lines        7616     7636      +20     
  Branches     1696     1704       +8     
==========================================
+ Hits         7119     7135      +16     
- Misses        497      501       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

cit-pr-commenter bot commented Aug 8, 2024

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 160.16 KiB 160.84 KiB 706 B +0.43%
Logs 55.98 KiB 55.98 KiB 0 B 0.00%
Rum Slim 108.76 KiB 109.45 KiB 706 B +0.63%
Worker 25.21 KiB 25.21 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.002 0.002 0.001
addaction 0.034 0.056 0.022
addtiming 0.001 0.001 0.001
adderror 0.034 0.069 0.035
startstopsessionreplayrecording 0.941 1.120 0.178
startview 1.001 1.019 0.018
logmessage 0.026 0.024 -0.002
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 17.80 KiB 20.39 KiB 2.59 KiB
addaction 69.91 KiB 72.41 KiB 2.49 KiB
addtiming 15.06 KiB 16.04 KiB 999 B
adderror 83.46 KiB 84.34 KiB 900 B
startstopsessionreplayrecording 13.27 KiB 12.40 KiB -896 B
startview 346.04 KiB 351.89 KiB 5.85 KiB
logmessage 64.91 KiB 69.96 KiB 5.05 KiB

🔗 RealWorld

@nulrich nulrich marked this pull request as ready for review August 8, 2024 16:43
@nulrich nulrich requested a review from a team as a code owner August 8, 2024 16:43
Copy link
Collaborator

@thomas-lebeau thomas-lebeau left a comment

Choose a reason for hiding this comment

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

❓ question: If i understand correctly, custom vitals are used in web-ui already, and this PR introduce a minor breaking change (renaming details to description).
How do we plan to release this?

packages/rum-core/src/boot/rumPublicApi.ts Outdated Show resolved Hide resolved
packages/rum-core/src/boot/rumPublicApi.ts Outdated Show resolved Hide resolved
@nulrich nulrich requested a review from amortemousque August 20, 2024 11:23
Co-authored-by: Aymeric <[email protected]>
* Stop a custom duration vital
* stored in @vital.custom.<name>
*
* @param name name of the custom vital
* @param nameOrRef name of the custom vital or the reference to it
Copy link
Collaborator

@amortemousque amortemousque Aug 26, 2024

Choose a reason for hiding this comment

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

💬 suggestion: ‏We could give more detail on when to use the ref or the name and the limitations. Maybe say to favour refs to avoid any concurrent vital issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

})

it('should not create multiple duration vitals by calling "stop" on the same vital instance multiple times', () => {
it('should not create multiple duration vitals by calling "stopDurationVital" on the same vital multiple times', () => {
Copy link
Collaborator

@amortemousque amortemousque Aug 26, 2024

Choose a reason for hiding this comment

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

💬 suggestion: It would be clearer if you split this test. One when using refs and another when using names‏

Copy link
Member

Choose a reason for hiding this comment

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

*split 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -30,78 +32,112 @@ describe('vitalCollection', () => {
})

describe('custom duration', () => {
describe('createVitalInstance', () => {
it('should create duration vital from a vital instance', () => {
describe('startDurationVital', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 suggestion: ‏You could add a test explaining what happens when creating multiple vitals with the same name and using stop with the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const vital = vitalCollection.startDurationVital({
name: 'foo',
it('should create a vital from start API using name', () => {
vitalCollection.startDurationVital('foo', {
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: ‏group vitalCollection tests together with a describe('startVitalCollection'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Mmh what confused me is that we have tests for both startDurationVital and vitalCollection.startDurationVital at the same level. I would expect the module-level startDurationVital tests to be independent from tests needing startVitalCollection.

@nulrich nulrich merged commit 894acbb into main Aug 28, 2024
20 checks passed
@nulrich nulrich deleted the nicolas.ulrich/custom-vitals-v3 branch August 28, 2024 09:24
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