w3c / server-timing

Server Timing
http://w3c.github.io/server-timing/
Other
75 stars 20 forks source link

Linking to ResourceTiming #14

Closed nicjansma closed 7 years ago

nicjansma commented 7 years ago

Because ServerTiming hard-codes 0 for the startTime, it's hard to associate ServerTiming entries with their corresponding entries in ResourceTiming.

For URLs that are only fetched once on the page, you can filter to ResourceTimings that have the same name.

But if a URL is fetched more than once, you can't definitively say which ServerTimings relate to other ResourceTimings, other than guessing based on the order. But that might not work if ServerTimings are non-deterministic (happening 0, 1 or many times).

Would we be able to come up with a way of "linking" them better? Maybe:

  1. A unique ID that both ServerTiming and ResourceTiming use to link each other. I thought we had discussed this before, but I couldn't find an issue in any of the RT, ST or PT repos.

  2. Similarly, ServerTiming could have a resourceStartTime attribute that would be equal to the startTime in the corresponding ResourceTiming entry.

  3. ResourceTiming could have a list of ServerTiming objects on its entry.

Thoughts? I realize fetching the same URL multiple times may not be the common case, but it would be nice to ensure we can have confidence in linking the two.

cvazac commented 7 years ago

As a developer, I think that the most consumable way to do this is 3. because it eliminates the need to "stitch" data of different types together with an ID, index, or startTime. It also uses less memory than 1. or 2.

WDYT? cc @igrigorik @yoavweiss

igrigorik commented 7 years ago

Should we consider hanging ST data off the resource timing object instead? That is, merge ST into Resource Timing? I can't think of any use case where ST data is meaningfully separate from the associated RT object?

cvazac commented 7 years ago

Yes, that's exactly what we're suggesting with 3. :)

PerformanceResourceTiming = {
  connectEnd: 343.98, 
  connectStart: 343.98, 
  decodedBodySize: 5087, 
  domainLookupEnd: 343.98, 
  domainLookupStart: 343.98, 
  duration: 45.11500000000001, 
  encodedBodySize: 5087, 
  entryType: "resource", 
  fetchStart: 343.98, 
  initiatorType: "img", 
  name: "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png", 
  redirectEnd: 0, 
  redirectStart: 0, 
  requestStart: 344.51000000000005, 
  responseEnd: 389.095, 
  responseStart: 345.58500000000004, 
  secureConnectionStart: 0, 
  startTime: 343.98, 
  transferSize: 0, 
  workerStart: 0, 
  serverEntries: [{
    description: "Total Response Time" 
    duration: 123.4,
    entryType: "server",
    metric: "trt"
    startTime: 0
  }, ... ]
}
igrigorik commented 7 years ago

Resolved via https://github.com/w3c/server-timing/pull/15.