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 navigation timing event #1919

Open
wants to merge 2 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
47 changes: 47 additions & 0 deletions docs/browser/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--- 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.

## Navigation Timing Event

<!-- semconv event.browser.navigation_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.navigation_timing`.

This event describes the timing metrics of a page navigation as provided by the PerformanceNavigationTiming Performance API.

This event captures data from the [Navigation Timing API](https://www.w3.org/TR/navigation-timing-2/). It is recommended to be captured by using the PerformanceObserver API, or when the window load event fires. 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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This event captures data from the [Navigation Timing API](https://www.w3.org/TR/navigation-timing-2/). It is recommended to be captured by using the PerformanceObserver API, or when the window load event fires. 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.
This event captures data from the [Navigation Timing API](https://www.w3.org/TR/navigation-timing-2/). It is recommended to be captured by using the PerformanceObserver API, or when the window load event fires. 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.

This event definition elevates a few key data points to body fields in order to make it easier to access. In addition, the complete set of data from the API may be sent in the body of the event as stringified JSON.

**Body fields:**

| Body Field | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `domComplete` | double | The time immediately before the user agent sets the document's readyState to "complete". The value is relative to the start of the navigation, and it is measured in milliseconds. | `506.5` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `domContentLoadedEventEnd` | double | The time immediately after the current document's DOMContentLoaded event handler completes. The value is relative to the start of the navigation, and it is measured in milliseconds. | `189.0` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `domInteractive` | double | the time immediately before the user agent sets the document's readyState to "interactive". The value is relative to the start of the navigation, and it is measured in milliseconds. | `147.70000000018626` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `fetchStart` | double | The time immediately before the browser starts to fetch the resource. The value is relative to the start of the navigation, and it is measured in milliseconds. | `9.600000000558794` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `loadEventEnd` | double | The time immediately after the current document's load event handler completes. The value is relative to the start of the navigation, and it is measured in milliseconds. | `506.70000000018626` | `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) |
| `unloadEventStart` | double | The time immediately before the current document's unload event handler starts. The value is relative to the start of the navigation, and it is measured in milliseconds. | `0.0` | `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
85 changes: 85 additions & 0 deletions model/browser/events.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
groups:
- id: event.browser.navigation_timing
stability: development
type: event
name: browser.navigation_timing
brief: >
This event describes the timing metrics of a page navigation as provided
by the PerformanceNavigationTiming Performance API.
note: >
This event captures data from the [Navigation Timing API](https://www.w3.org/TR/navigation-timing-2/).
It is recommended to be captured by using the PerformanceObserver API, or
when the window load event fires. 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.

This event definition elevates a few key data points to body fields in
order to make it easier to access. In addition, the complete set of data
from the API may be sent in the body of the event as stringified JSON.
body:
id: browser.navigation_timing
requirement_level: required
stability: development
type: map
fields:
- id: name

Check failure on line 26 in model/browser/events.yaml

View workflow job for this annotation

GitHub Actions / yamllint

[trailing-spaces] trailing spaces

Check failure on line 26 in model/browser/events.yaml

View workflow job for this annotation

GitHub Actions / yamllint

[trailing-spaces] trailing spaces
type: string
stability: development
brief: The resolved URL of the requested resource.

Check failure on line 29 in model/browser/events.yaml

View workflow job for this annotation

GitHub Actions / yamllint

[trailing-spaces] trailing spaces

Check failure on line 29 in model/browser/events.yaml

View workflow job for this annotation

GitHub Actions / yamllint

[trailing-spaces] trailing spaces
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. The value is relative to the start of the navigation, and
it is measured in milliseconds.
requirement_level: recommended
examples: [9.600000000558794]
- id: unloadEventStart
type: double
stability: development
brief: >
The time immediately before the current document's unload event
handler starts. The value is relative to the start of the
navigation, and it is measured in milliseconds.
requirement_level: recommended
examples: [0.0]
- id: domInteractive
type: double
stability: development
brief: >
the time immediately before the user agent sets the document's
readyState to "interactive". The value is relative to the start of
the navigation, and it is measured in milliseconds.
requirement_level: recommended
examples: [147.70000000018626]
- id: domContentLoadedEventEnd
type: double
stability: development
brief: >
The time immediately after the current document's DOMContentLoaded
event handler completes. The value is relative to the start of the
navigation, and it is measured in milliseconds.
requirement_level: recommended
examples: [189.0]
- id: domComplete
type: double
stability: development
brief: >
The time immediately before the user agent sets the document's
readyState to "complete". The value is relative to the start of the
navigation, and it is measured in milliseconds.
Comment on lines +71 to +74
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest moving the second sentence to the note (to make the brief shorter)

and maybe add links to the properties in each case, to be super explicit that these are defined externally, e.g. https://www.w3.org/TR/navigation-timing-2/#dom-performancenavigationtiming-domcomplete

requirement_level: recommended
examples: [506.5]
- id: loadEventEnd
type: double
stability: development
brief: >
The time immediately after the current document's load event handler
completes. The value is relative to the start of the navigation, and
it is measured in milliseconds.
requirement_level: recommended
examples: [506.70000000018626]
Loading