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

Support for Server-Timing #302

Closed
rviscomi opened this issue Jan 5, 2023 · 5 comments · Fixed by #324
Closed

Support for Server-Timing #302

rviscomi opened this issue Jan 5, 2023 · 5 comments · Fixed by #324

Comments

@rviscomi
Copy link
Member

rviscomi commented Jan 5, 2023

If a document includes Server-Timing headers, it could be useful to report that as TTFB diagnostic data in the RUM beacon. Is there anything this library can do to better support this kind of data?

This is a follow up to #203 by @malchata which originally proposed tracking Server-Timing, but AFAICT it wasn't ultimately added to the attribution build. Is there any additional context behind that decision, or worth reevaluating?

@philipwalton
Copy link
Member

Did you have a specific API design idea in mind? Right now it's pretty easy to get server timing data in either the standard or attribution build:

onTTFB((metric) => {
  console.log(metric.entries[0]?.serverTiming);
});

Given that server timing info so site-specific, I'm not sure if we need more sugar on top of what we already have?

@malchata
Copy link
Member

malchata commented Jan 5, 2023

I think a bit of sugar could make this a bit more approachable, IMO:

onTTFB((metric) => {
  // Server-Timing entries for the navigation request:
  console.log(metric?.serverTiming);
});

@tunetheweb
Copy link
Member

Adding the serverTiming value to the TTFB attribution object could be one way to surface this more readily, rather than someone knowing how to grab this via metric.entries[0]?.serverTiming.

Seems inline with how the other metrics were handled for #203

@philipwalton
Copy link
Member

If you're using the attribution build, you can get the server timing value like this:

onTTFB((metric) => {
  console.log(metric.attribution.navigationEntry?.serverTiming);
});

Which isn't much different from @malchata's example:

+ console.log(metric.attribution.serverTiming);
- console.log(metric.attribution.navigationEntry?.serverTiming);

Every other property of each attribution object is a calculation of some sort, so it feels a bit arbitrary to add sugar for this one and not others. And if we add it for others then we're increasing code size quite a bit for values that most people aren't using.

@tunetheweb
Copy link
Member

Think I'm with @philipwalton now. But let's document this as an example to make it more obvious how to access. Opened #324 for that.

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 a pull request may close this issue.

4 participants