HTTPArchive / custom-metrics

Custom metrics to use with WebPageTest agents
Apache License 2.0
19 stars 21 forks source link

Capture speculation rules usage #109

Closed rviscomi closed 9 months ago

rviscomi commented 9 months ago

Adds a speculation_rules field to the performance custom metric. It's an array mapping each script[type=speculationrules] element to its JSON contents.

Post-processing in BigQuery is required to extract meaningful stats.


Test websites:

github-actions[bot] commented 9 months ago
Custom metrics for https://almanac.httparchive.org/en/2022/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=240131_FM_2
Custom metrics for https://rviscomi.dev/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=240131_XC_3 Changed custom metrics values: ```json { "_performance": { "lcp_elem_stats": { "startTime": 1105.2000000029802, "nodeName": "P", "url": "", "size": 84071, "loadTime": 0, "renderTime": 1105.2000000029802, "attributes": [ { "name": "class", "value": "wp-block-post-excerpt__excerpt" } ], "boundingClientRect": { "x": 75.5, "y": 458.46875, "width": 385, "height": 230.375, "top": 458.46875, "right": 460.5, "bottom": 688.84375, "left": 75.5 }, "styles": { "background-image": "none", "pointer-events": "auto", "position": "static", "width": "385px", "height": "230.375px" }, "percentOfViewport": "0.0940", "cover90viewport": false }, "raw_lcp_element": null, "lcp_resource": null, "is_lcp_statically_discoverable": true, "is_lcp_preloaded": null, "lcp_preload": null, "web_vitals_js": [ "https://unpkg.com/web-vitals@3.5.2/dist/web-vitals.attribution.js?module" ], "gaming_metrics": [], "speculation_rules": [ { "prerender": [ { "source": "document", "where": { "and": [ { "href_matches": "/*" }, { "not": { "href_matches": [ "/wp-login.php", "/wp-admin/*" ] } }, { "not": { "selector_matches": ".no-prerender" } } ] }, "eagerness": "moderate" } ] } ] } } ```
Custom metrics for https://www.scalemates.com/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=240131_63_4 Changed custom metrics values: ```json { "_performance": { "lcp_elem_stats": { "startTime": 712.2999999970198, "nodeName": "IMG", "url": "https://www.scalemates.com/static/scm.svg", "size": 22896, "loadTime": 471.79999999701977, "renderTime": 712.2999999970198, "attributes": [ { "name": "fetchpriority", "value": "high" }, { "name": "class", "value": "ha w1 pnw" }, { "name": "src", "value": "/static/scm.svg" }, { "name": "alt", "value": "Logo" }, { "name": "title", "value": "Home" }, { "name": "elementtiming", "value": "Logo" } ], "boundingClientRect": { "x": 150.53125, "y": 7.03125, "width": 432.3125, "height": 53.328125, "top": 7.03125, "right": 582.84375, "bottom": 60.359375, "left": 150.53125 }, "naturalWidth": 300, "naturalHeight": 37, "styles": { "background-image": "none", "pointer-events": "auto", "position": "absolute", "width": "432.312px", "height": "53.3281px" }, "percentOfViewport": "0.0244", "cover90viewport": false }, "raw_lcp_element": null, "lcp_resource": { "id": "81", "sequence": 35, "url": "https://www.scalemates.com/static/scm.svg", "request_headers": { "method": "GET", "authority": "www.scalemates.com", "scheme": "https", "path": "/static/scm.svg", "accept": "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8", "sec-fetch-site": "same-origin", "sec-fetch-mode": "no-cors", "sec-fetch-dest": "image", "referer": "https://www.scalemates.com/", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en;q=0.9" }, "response_headers": { "status": "200", "content-type": "image/svg+xml", "content-encoding": "br", "last-modified": "Sat, 13 May 2023 14:49:08 GMT", "vary": "Accept-Encoding", "content-length": "1136", "cache-control": "public, max-age=31536000", "date": "Wed, 31 Jan 2024 03:26:47 GMT" }, "initialPriority": "Low", "priority": "Low", "body": "/home/pmeenan/wptagent/work/wptagent-manual-221206-10.240.0.22/240131_63_4.1.0/netlog_bodies/81" }, "is_lcp_statically_discoverable": false, "is_lcp_preloaded": false, "lcp_preload": [], "web_vitals_js": [], "gaming_metrics": [], "speculation_rules": [ { "prerender": [ { "source": "document", "where": { "selector_matches": ".pf, .ac a" }, "eagerness": "conservative" } ] } ] } } ```
Custom metrics for https://example.com/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=240131_F3_5 Changed custom metrics values: ```json { "_performance": { "lcp_elem_stats": { "startTime": 288.09999999403954, "nodeName": "P", "url": "", "size": 33858, "loadTime": 0, "renderTime": 288.09999999403954, "attributes": [], "boundingClientRect": { "x": 383, "y": 192.875, "width": 600, "height": 57, "top": 192.875, "right": 983, "bottom": 249.875, "left": 383 }, "styles": { "background-image": "none", "pointer-events": "auto", "position": "static", "width": "600px", "height": "57px" }, "percentOfViewport": "0.0362", "cover90viewport": false }, "raw_lcp_element": null, "lcp_resource": null, "is_lcp_statically_discoverable": true, "is_lcp_preloaded": null, "lcp_preload": null, "web_vitals_js": [], "gaming_metrics": [], "speculation_rules": [] } } ```
Custom metrics for https://web.dev/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=240131_E4_6 Changed custom metrics values: ```json {} ```