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

rfc(informational): Achieving order between Pageload and SRR spans #138

Merged
merged 6 commits into from
Jul 24, 2024

Conversation

lforst
Copy link
Member

@lforst lforst commented Jul 12, 2024

This is an RFC to discuss how to flip the order between Pageload and SSR spans to improve user experience.

Rendered RFC

Just some slack convos for posterity:

Screenshot 2024-07-26 at 09 55 56 Screenshot 2024-07-26 at 09 56 27 Screenshot 2024-07-26 at 09 56 51 Screenshot 2024-07-26 at 09 57 24 Screenshot 2024-07-26 at 09 57 43

@lforst lforst force-pushed the rfc/achieving-order-between-pageload-and-srr-spans branch from e5dfea6 to 872021f Compare July 12, 2024 11:42
@lforst lforst marked this pull request as ready for review July 12, 2024 12:31
@lforst lforst self-assigned this Jul 15, 2024
Copy link
Member

@JonasBa JonasBa left a comment

Choose a reason for hiding this comment

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

I am +1 on doing the UI approach, it requires the least amount of eng investment and will allow us to validate the idea.

There are some unknowns that I think we should write down:

  • Do we know or expect to ever have to query by such a relationship? This would mean that we would need to store this and would require flipping the order in the SDK
  • How do other observability providers tackle this? We are probably not the only ones with this issue so lets see if there are other approaches we are not considering

Comment on lines +8 to +10
The hierarchy between Pageload Spans and SSR Spans is currently very confusing.
SSR Spans are the ancestors of Pageload Spans, even though in a real-world scenario the Pageload is always the first thing that happens.
This document discusses how this came to be and how it could be improved.
Copy link
Member

Choose a reason for hiding this comment

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

This sounds like a tradeoff between correctness and what someone might intuitively expect. My initial thought seeing that screenshot was that pageload would be the parent span, but when you think about it, it makes perfect sense that it is not.

Copy link
Member Author

Choose a reason for hiding this comment

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

In my opinion, it is not entirely just a tradeoff between correctness and intuition.

Just by looking at the order of execution, currently, the trace has the wrong topology: First the browser starts requesting the page, then the server responds. The trace shows it the other way around.
SDK-wise the trace is currently correct: The server SDK initializes before the browser SDK initializes.

The thing is, users likely don't care about the SDK, they care about the timings and topology of their application.

Copy link
Member

@JonasBa JonasBa Jul 22, 2024

Choose a reason for hiding this comment

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

The thing is, users likely don't care about the SDK, they care about the timings and topology of their application.

Agree. Do we know how other providers tackle this problem, do they just ignore it?

Comment on lines +47 to +49
The drawbacks of flipping the order in the SDK is that we would make the data incorrect:
By optimistically setting the `parent_span_id` of the SSR Span, we may run into situations where we unintentionally orphan that span, for example when somebody requests the page with a non-browser client that will never run the Browser SDK.
Span orphaning could however be mitigated, if we let the SDK set an additional attribute that informs Sentry about the fact that the `parent_span_id` on the SSR transaction is optimistic (e.g. `sentry.has_optimistic_parent_span_id`).
Copy link
Member

Choose a reason for hiding this comment

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

This sounds brittle so I would try and avoid this.

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO not super brittle, but yes, I would also like to avoid this.


Flipping at read time is hard because you would need all the spans of the entire trace to make an informed flipping decision. It is not enough to just look at transaction hierarchy.

Flipping the order when querying (ie. when loading the trace view or even purely having custom logic in the UI) might be another viable option.
Copy link
Member

Choose a reason for hiding this comment

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

I'm +1 on doing this as the first approach and reevaluating if we need to.

@JonasBa
Copy link
Member

JonasBa commented Jul 18, 2024

@lforst It just occurred to me, but I think the only reason this doesnt make sense to me visually is because the start time of a child ends up being before the start time of its parent, breaking the "children are contained inside parent" rule.

In that case, instead of reparenting, could we consider an alternative approach where we would shift the start of the SSR span to match the start of the pageload span?

CleanShot 2024-07-17 at 21 29 43@2x

In this case, it would then look like the SSR span started at 0, same as the pageload span below it and visually containing it

@lforst
Copy link
Member Author

lforst commented Jul 22, 2024

In that case, instead of reparenting, could we consider an alternative approach where we would shift the start of the SSR span to match the start of the pageload span?

@JonasBa That would make the timings wrong. The pageload span starts when the browser starts requesting the page which is always before the server will start handling the request. Moving the server span to the left is entirely wrong and therefore not an option.

@lforst lforst merged commit 06893a5 into main Jul 24, 2024
4 checks passed
@lforst lforst deleted the rfc/achieving-order-between-pageload-and-srr-spans branch July 24, 2024 09: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.

2 participants