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

Allow linking the server-side HTML render with client side HTML fetch spans #457

Closed
draffensperger opened this issue Oct 23, 2019 · 1 comment · Fixed by #477
Closed
Assignees
Milestone

Comments

@draffensperger
Copy link
Contributor

When an HTML page is loaded, it's nice to be able to see the overall page load as a span with a span for the initial HTML fetch as well. If the HTML fetch is slow, it's nice to see what on the server took a while (e.g. database calls, view render, etc.). This would be a feature request for the DocumentLoad plugin to make this work.

To get the server and client spans joined for the HTML fetch, we need the trace context to be shared between the client and server for an HTML load. Because the client in this case (the browser) does not send a trace header for the initial page load, we need an alternate mechanism.

What we can do is to have the server send back its trace ID, and make its server-side span for the initial page load have a random span ID as its parent. Then it passes back that parent ID to the browser client, which uses it as the span ID for its client-side fetch. That way we link the spans without needing to pass trace context as a header, which is not possible given the current browser spec for an initial navigation fetch.

Similarly, we will want to pass the trace sampling decision from the server to the client so that the trace sampling of both are aligned such that the user gets full end-to-end traces.

Here are two possibilities for how the server can send the trace ID back to the client:

  1. Have the server write a global variable, maybe something called otTraceparent or similar. We used this approach in OpenCensus Web, see its Send a trace parent and sampling decision from your server docs, and this code link
  2. We could encode the trace ID, span ID and sampling decision (basically the trace parent header) as an entry in the Server-Timing header. This could be useful in some contexts, but feels a little hackier than passing the trace header as a global variable.

I recommend we start with option 1, and then get to option 2 at some point in the future.

cc/ @jahtalab

What do you think @obecny about this feature request?

@mayurkale22 mayurkale22 added this to To do in Browser Tracer via automation Oct 24, 2019
@mayurkale22 mayurkale22 added this to the Alpha v0.3 milestone Oct 31, 2019
@obecny
Copy link
Member

obecny commented Nov 1, 2019

please assign this to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants