Skip to content

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented Nov 26, 2025

This PR fixes two issues but to be honest, I'm a bit unsure of all consequences. Would appreciate a thorough review from someone who actually knows the waterfall view :)

  1. While fixing fix(waterfall): Relax "next_trace" lookup to just the trace id #104047, I also noticed that we had a similar problem for the "previous trace" button:

    If we look at a trace in the waterfall where the first root span is not a navigation/pageload span but e.g. a web vital span, we can't look up the trace's previous_trace link. Therefore, we can only show the disabled "previous trace" button in the UI, although there actually is a previous trace.

  2. For EAP-based traces, it seems like we always took the first transaction event as the title of the current trace. This sometimes led to a bit sub optimal titles in my opinion. I noticed we had a more selective logic for none-EAP events, where we preferred the pageload, navigation and ui.load events over the "first" event.

To fix both of these issues, this PR ports the none-EAP logic of selecting a trace root to the EAP logic. Also kept the heuristic in place to prefer an EAP root event over a none-EAP event in case of mixed traces (?).

Before:
image

After:
image

@Lms24 Lms24 requested a review from a team as a code owner November 26, 2025 17:45
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 26, 2025
@Lms24 Lms24 changed the title fix(waterfall): Prefer frontend root events in trace root lookup fix(waterfall): Prefer specific root events in trace root lookup Nov 26, 2025
@JPeer264
Copy link
Member

For some reason (and this is also not working on master), the very first trace does not have the next button enabled. I could imagine that that worked once. Not sure if this PR is also meaning to fix this behavior.

  1. This is the very first trace
  2. This is the second trace

Copy link
Contributor

@nsdeschenes nsdeschenes left a comment

Choose a reason for hiding this comment

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

This all makes sense to me, tho would like a second set of eyes on it 😄

@Lms24
Copy link
Member Author

Lms24 commented Nov 27, 2025

For some reason (and this is also not working on master), the very first trace does not have the next button enabled. I could imagine that that worked once. Not sure if this PR is also meaning to fix this behavior.
This is the very first trace
This is the second trace

I debugged this and found that the environment of the trace root events is the problem here: The 1st trace root (http.server) has development while the second one has production. We filter on the environment in the useSpans call and hence the next trace lookup fails. I think we could just remove that filter but this is a separate issue from this PR. I also want to wait with this and first figure out if the diverging environments are user-configuration or just default config. If it's default, we might just have found a bug in the NextJS SDK 🤔

@JPeer264
Copy link
Member

Ya you are absolutely right. The environments are different. I'd be up for removing the env filter

Lms24 added a commit that referenced this pull request Nov 27, 2025
…ts (#104095)

Fixes
#104050 (comment)
where we discovered that if subsequent traces have different
environments, our lookup for the next trace fails.
@Lms24 Lms24 reopened this Nov 27, 2025
@Lms24
Copy link
Member Author

Lms24 commented Nov 27, 2025

(This was closed accidentally)

Copy link
Contributor

@Abdkhan14 Abdkhan14 left a comment

Choose a reason for hiding this comment

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

This makes sense to me!

@Lms24 lets apply the preferred-root logic to to both eap and non-eap traces, getting rid of the isEAPTransaction(event) check. I'm working towards mitigating type-guard usage in this space.

Also, we never expect there to be a mix of eap and non-eap events, we can get rid of eapRootEvent

@Lms24 Lms24 requested a review from Abdkhan14 November 28, 2025 10:42
@Lms24
Copy link
Member Author

Lms24 commented Nov 28, 2025

Thanks for the review @Abdkhan14. I got rid of the EAP-specific checks. Can you double check if this is still correct? My testing still shows the same behavior as before but I'm not sure if there is anything I missed with non-EAP events (are they even still a thing?)

Update: made two more changes (thx to AI review bots for catching):

  • extracted the preferred op lookup
  • ensured we still fall back to the first root event

Comment on lines 72 to 74
// We prefer certain root events over conventional root events.
// These make better titles in the waterfall view and make linked
// trace navigations work.

This comment was marked as outdated.

Copy link
Member Author

Choose a reason for hiding this comment

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

nice! totally missed this. But I'm not sure if it's actually a concern (see my Q about none-EAP here). Anyway, I extracted the now common logic.

Copy link
Contributor

@Abdkhan14 Abdkhan14 left a comment

Choose a reason for hiding this comment

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

Exactly what I was talking about 🚢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants