Skip to content

Commit 980126f

Browse files
Encourage custom metrics over response_body (#164)
* Encourage custom metrics over response_body * Apply suggestions from code review Co-authored-by: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Barry Pollard <barrypollard@google.com> * Apply suggestions from code review Co-authored-by: Barry Pollard <barrypollard@google.com> * Apply suggestions from code review Co-authored-by: Barry Pollard <barrypollard@google.com> --------- Co-authored-by: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
1 parent 4ed0417 commit 980126f

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

src/content/docs/reference/blobs/page-metadata.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,26 @@ JSON-encoded HTTP Archive metadata about the page that was tested.
3030
```
3131
</details>
3232

33+
:::note
34+
There is a lot of other page-level metadata in the [custom metrics](/reference/structs/custom-metrics/), which are custom pieces of JavaScript (see [source code](https://github.com/HTTPArchive/custom-metrics/)) run during the crawl to extract information from the page.
35+
36+
Check the custom metrics before falling back to `response_body`. Custom metrics include the post-JavaScript DOM, are far less brittle than regexing HTML, and are significantly faster and cheaper to query.
37+
38+
For example, to get the `title` and `meta_description` you can use:
39+
```sql
40+
SELECT
41+
page,
42+
custom_metrics.wpt_bodies.title.rendered.primary.text AS title,
43+
custom_metrics.wpt_bodies.meta_description.rendered.primary.text AS meta_description.
44+
FROM
45+
`httparchive.crawl.pages`
46+
WHERE
47+
...
48+
```
49+
50+
The [source code](https://github.com/HTTPArchive/custom-metrics/) of the custom metrics can be useful to understand exactly how they are collected.
51+
:::
52+
3353
## Schema
3454

3555
### `crawl_depth`

src/content/docs/reference/tables/requests.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,26 @@ See the [Header](/reference/structs/header/) reference for more details.
9898

9999
Text-based response body
100100

101+
:::note
102+
There is lots of extracted information in the [custom metrics](/reference/structs/custom-metrics/), which are custom pieces of JavaScript run during the crawl to extra information from the page.
103+
104+
Check the custom metrics before falling back to `response_body`. Custom metrics include the post-JavaScript DOM, are far less brittle than regexing HTML, and are significantly faster and cheaper to query.
105+
106+
For example, to get the `title` and `meta_description` you can use:
107+
```sql
108+
SELECT
109+
page,
110+
custom_metrics.wpt_bodies.title.rendered.primary.text AS title,
111+
custom_metrics.wpt_bodies.meta_description.rendered.primary.text AS meta_description.
112+
FROM
113+
`httparchive.crawl.pages`
114+
WHERE
115+
...
116+
```
117+
118+
The source of the [custom metrics](https://github.com/HTTPArchive/custom-metrics/) can be useful to understand exactly what is collected.
119+
:::
120+
101121
## Example queries
102122

103123
Here are some common operations you can perform with the `requests` table.

0 commit comments

Comments
 (0)