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

Add Browser Resource Timing Event #1943

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions docs/browser/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--- Hugo front matter used to generate the website version of this page:
linkTitle: Events
--->

# Semantic conventions for browser events

**Status**: [Development][DocumentStatus]

This document defines semantic conventions for browser (web) instrumentations
that emit events.

## Resource Timing Event

<!-- semconv event.browser.resource_timing -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->

**Status:** ![Development](https://img.shields.io/badge/-development-blue)

The event name MUST be `browser.resource_timing`.

This event describes the timing metrics as provided by PerformanceResourceTiming Performance API. These metrics are related to fetching a resource, such as XMLHttpRequest, Fetch, sendBeacon APIs, SVG, image or script.

This event captures data from the [ResourceTiming](https://www.w3.org/TR/resource-timing/). It is recommended to be captured by using the PerformanceResourceTiming API. If the page starts unloading before the page loads, then the partial data can be captured by calling the [performance.getEntriesByType](https://developer.mozilla.org/en-US/docs/Web/API/Performance/getEntriesByType) method.

**Body fields:**

| Body Field | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `connectEnd` | double | The time immediately after the browser finishes establishing the connection to the server to retrieve the resource. The timestamp value includes the time interval to establish the transport connection, as well as other time intervals such as SSL handshake and SOCKS authentication. completes, and it is measured in milliseconds. | `476.6000000014906` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `connectStart` | double | The time immediately immediately before the user agent starts establishing the connection to the server to retrieve the resource, and it is measured in milliseconds. | `476.6000000014901` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `domainLookupEnd` | double | The time immediately after the browser finishes the domain name lookup for the resource, and it is measured in milliseconds. | `100.6000000014906` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `domainLookupStart` | double | The time immediately before the browser starts the domain name lookup for the resource, and it is measured in milliseconds. | `100.6000000014901` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `fetchStart` | double | The time immediately before the browser starts to fetch the resource, and it is measured in milliseconds. | `9.600000000558794` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `name` | string | The resolved URL of the requested resource. | `https://en.wikipedia.org/wiki/Main_Page` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `requestStart` | double | The time immediately before the browser starts requesting the resource from the server, cache, or local resource. If the transport connection fails and the browser retires the request, the value returned will be the start of the retry request, and it is measured in milliseconds. | `506.70000000298023` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `responseEnd` | double | The time immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first, and it is measured in milliseconds. | `510.6000000014906` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `responseStart` | double | The time immediately after the browser receives the first byte of the response from the server, cache, or local resource, and it is measured in milliseconds. | `508.6000000014901` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `secureConnectionStart` | double | The time immediately before immediately before the browser starts the handshake process to secure the current connection, and it is measured in milliseconds. | `476.6000000014903` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status
104 changes: 104 additions & 0 deletions model/browser/events.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
groups:
- id: event.browser.resource_timing
stability: development
type: event
name: browser.resource_timing
brief: >
This event describes the timing metrics as provided by PerformanceResourceTiming Performance API.
These metrics are related to fetching a resource, such as
XMLHttpRequest, Fetch, sendBeacon APIs, SVG, image or script.
note: >
This event captures data from the [ResourceTiming](https://www.w3.org/TR/resource-timing/).
It is recommended to be captured by using the PerformanceResourceTiming API.
If the page starts unloading before the page loads,
then the partial data can be captured by calling the [performance.getEntriesByType](https://developer.mozilla.org/en-US/docs/Web/API/Performance/getEntriesByType) method.

body:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see a comment here to clarify that this is temporary or that this will actually be an attribute. That way readers do not expect to find content in the actual body.

id: browser.resource_timing
requirement_level: required
stability: development
type: map
fields:
- id: name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think name is the right thing for a url here. Maybe just url would be more concise?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, now that url.full is stable maybe we should consider lifting this to a top level attribute, where from an instrumentation perspective it would include the full redacted query string -- although for this event you "generally" don't need the full url, just the scheme, domain and path -- but splitting out to 3 different attributes doesn't really fit the need of this event....

Lets change this to url and add wording that it explicitly doesn't include the query string or any leading credentials (so it's formatted as <scheme>:\\<full domain>\<path> only
What I mean by this is that
https://username:password@www.example.com/path?a=b&c=d would be sent as https://www.example.com/path basically both removing any potential PII and reducing the cardinality of the name.

type: string
stability: development
brief: The resolved URL of the requested resource.
requirement_level: recommended
examples: ["https://en.wikipedia.org/wiki/Main_Page"]
- id: fetchStart
type: double
stability: development
brief: >
The time immediately before the browser starts to fetch the resource,
and it is measured in milliseconds.
requirement_level: recommended
examples: [9.600000000558794]
- id: domainLookupStart
type: double
stability: development
brief: >
The time immediately before the browser starts the domain name lookup for the resource,
and it is measured in milliseconds.
requirement_level: recommended
examples: [100.6000000014901]
- id: domainLookupEnd
type: double
stability: development
brief: >
The time immediately after the browser finishes the domain name lookup for the resource,
and it is measured in milliseconds.
requirement_level: recommended
examples: [100.6000000014906]
- id: connectStart
type: double
stability: development
brief: >
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to reformat/shorten the brief to make the generated table look nicer

The time immediately immediately before the user agent starts establishing the connection to the server to retrieve the resource,
and it is measured in milliseconds.
requirement_level: recommended
examples: [476.6000000014901]
- id: secureConnectionStart
type: double
stability: development
brief: >
The time immediately before immediately before the browser starts the handshake process to secure the current connection,
and it is measured in milliseconds.
requirement_level: recommended
examples: [476.6000000014903]
- id: connectEnd
type: double
stability: development
brief: >
The time immediately after the browser finishes establishing the connection to the server to retrieve the resource.
The timestamp value includes the time interval to establish the transport connection,
as well as other time intervals such as SSL handshake and SOCKS authentication.
completes, and it is measured in milliseconds.
requirement_level: recommended
examples: [476.6000000014906]
- id: requestStart
type: double
stability: development
brief: >
The time immediately before the browser starts requesting the resource from the server, cache, or local resource.
If the transport connection fails and the browser retires the request,
the value returned will be the start of the retry request,
and it is measured in milliseconds.
requirement_level: recommended
examples: [506.70000000298023]
- id: responseStart
type: double
stability: development
brief: >
The time immediately after the browser receives the first byte of the response from the server, cache, or local resource,
and it is measured in milliseconds.
requirement_level: recommended
examples: [508.6000000014901]
- id: responseEnd
type: double
stability: development
brief: >
The time immediately after the browser receives the last byte of the resource
or immediately before the transport connection is closed, whichever comes first,
and it is measured in milliseconds.
requirement_level: recommended
examples: [510.6000000014906]
Loading