Merged
Conversation
Lms24
approved these changes
May 31, 2024
Member
Lms24
left a comment
There was a problem hiding this comment.
Good catch!
Any chance we can test this reliably? No worries if not or if it'd be too much work; was just wondering
Contributor
size-limit report 📦
|
Member
Author
|
Yeah not 100% sure yet, none of our tests has caught this, I guess because it will only really be noticeable if one of the performance spans, for whatever reason, has an earlier start or end timestamp, which does not seem to happen all the time but sometimes 🤔 maybe I can simulate it somehow at least... |
03e6338 to
a4efccc
Compare
Member
Author
|
I adjusted a test to ensure this actually works (the test failed before)! |
4732edf to
f3666ed
Compare
c298lee
pushed a commit
that referenced
this pull request
Jun 4, 2024
I noticed here https://github.com/getsentry/sentry-javascript/pulls that some tests were becoming flaky. Investigating this some more, I figured out what was happening: 1. For idle spans, when the span is ended (in `on('spanEnded')`, which is triggered in `span.end()`), we call `onIdleSpanEnded` 2. In there, we call `beforeSpanEnd` 3. This is used by `browserTracingIntegration` to call `addPerformanceEntries(span)`, which adds performance spans to the idle span 4. After that, in `onIdleSpanEnded`, any spans having start/end timestamps outside of the idle span start/end timestamp will be discarded This lead to cases where performance spans were discarded because they were out of bounds of the idle span - which is not what we want! Now, this PR changes the timing of this a bit: Now, we actually patch `span.end` of the SentrySpan, to ensure that we can always run `beforeSpanEnd` with the correct timing, taking all spans that are added in `beforeSpanEnd` into account to adjust the start/end time of the idle span.
This was referenced Jul 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I noticed here https://github.com/getsentry/sentry-javascript/pulls that some tests were becoming flaky. Investigating this some more, I figured out what was happening:
on('spanEnded'), which is triggered inspan.end()), we callonIdleSpanEndedbeforeSpanEndbrowserTracingIntegrationto calladdPerformanceEntries(span), which adds performance spans to the idle spanonIdleSpanEnded, any spans having start/end timestamps outside of the idle span start/end timestamp will be discardedThis lead to cases where performance spans were discarded because they were out of bounds of the idle span - which is not what we want!
Now, this PR changes the timing of this a bit:
Now, we actually patch
span.endof the SentrySpan, to ensure that we can always runbeforeSpanEndwith the correct timing, taking all spans that are added inbeforeSpanEndinto account to adjust the start/end time of the idle span.