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

ref(browser): Improve browserMetrics collection #13062

Merged
merged 1 commit into from
Aug 2, 2024
Merged

ref(browser): Improve browserMetrics collection #13062

merged 1 commit into from
Aug 2, 2024

Conversation

horochx
Copy link
Contributor

@horochx horochx commented Jul 26, 2024

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Hey @horochx thanks for opening this PR!

(heads-up: I'm only assigning myself for internal tracking purposes since I'm reviewing this PR)

If I understand the changes correctly, moving the getActiveSpan checks out of the loop is meant as a slight performance improvement, correct? I think that's okay (though only marginally faster because we'd return in the first iteration anyway).

I still had one question but after it is addressed, we can merge this.

For the future as well as for this PR: Please add a brief description of the changes to the PR description. That would be much appreciated, especially if there's no issue with more context. Thanks!

if (!entry.scripts[0]) {
return;
break;
Copy link
Member

Choose a reason for hiding this comment

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

This is a behaviour change. Would you mind explaining why we should break 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.

Thank you for pointing that out. It was a typo, and I have corrected it to continue. The change from return to continue is to ensure that the remaining entry containing initialScript in list.getEntries() are not skipped and are reported properly.

@Lms24 Lms24 self-assigned this Jul 26, 2024
if (!entry.scripts[0]) {
return;
continue;
Copy link
Member

Choose a reason for hiding this comment

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

Is there a bug that this change fixes? I think it's probably fine to go through all entries but I'm curious.

Copy link
Member

Choose a reason for hiding this comment

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

@KevinL10 would you mind checking if this is fine? I believe you added the long animation frame instrumentation so I'd like to run it by you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I'm currently on a bus and can't reply promptly.

Here's my use case:
I asynchronously load Sentry and have just started optimizing performance. Upon initial execution of the LoAF callback, I found that the entry in the callback contains items with scripts and items without scripts. The current behavior skips reporting the remaining items with scripts after encountering one without scripts, so I've modified this behavior.

Once again, thank you for your review.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! This fix makes sense to me.

@Lms24 Lms24 requested a review from KevinL10 July 26, 2024 13:22
if (sourceCharPosition !== -1) {
attributes['browser.script.source_char_position'] = sourceCharPosition;
}
const { invoker, invokerType, sourceURL, sourceFunctionName, sourceCharPosition } = initialScript;
Copy link
Member

Choose a reason for hiding this comment

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

why was this guard removed?

We kept this here intentionally to ensure that we wouldn't do assignment unless the array item was defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello,

At line 136,


already checks for scripts, so I have removed the redundant check here.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Thanks for contributing and also thanks @KevinL10 for reviewing! We'll merge this soon. Expect it to be released later this week with the next version after 8.21.0.

@Lms24 Lms24 changed the title Update browserMetrics.ts ref(browser): Improve browserMetrics collection Aug 2, 2024
@Lms24 Lms24 merged commit 2b7fa21 into getsentry:develop Aug 2, 2024
117 checks passed
AbhiPrasad pushed a commit that referenced this pull request Aug 2, 2024
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #13062

Co-authored-by: Lms24 <[email protected]>
@horochx horochx deleted the patch-1 branch August 5, 2024 02:14
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.

4 participants