Skip to content

Commit

Permalink
Add mobile and language semconv for browser resource (#2761)
Browse files Browse the repository at this point in the history
  • Loading branch information
scheler authored Sep 20, 2022
1 parent 9920d5e commit 6a8fcfa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ release.

### Resource

- Add `browser.mobile` and `browser.language` resource attributes
([#2761](https://github.com/open-telemetry/opentelemetry-specification/pull/2761))

### Semantic Conventions

### Compatibility
Expand Down
21 changes: 18 additions & 3 deletions semantic_conventions/resource/browser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,33 @@ groups:
note: >
This value is intended to be taken from the
[UA client hints API](https://wicg.github.io/ua-client-hints/#interface)
(navigator.userAgentData.brands).
(`navigator.userAgentData.brands`).
examples: [" Not A;Brand 99", "Chromium 99", "Chrome 99"]
- id: platform
type: string
brief: 'The platform on which the browser is running'
note: >
This value is intended to be taken from the
[UA client hints API](https://wicg.github.io/ua-client-hints/#interface)
(navigator.userAgentData.platform). If unavailable, the legacy
(`navigator.userAgentData.platform`). If unavailable, the legacy
`navigator.platform` API SHOULD NOT be used instead and this attribute
SHOULD be left unset in order for the values to be consistent.
The list of possible values is defined in the
[W3C User-Agent Client Hints specification](https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform).
Note that some (but not all) of these values can overlap with values
in the [os.type and os.name attributes](./os.md).
in the [`os.type` and `os.name` attributes](./os.md).
However, for consistency, the values in the `browser.platform` attribute
should capture the exact value that the user agent provides.
examples: ['Windows', 'macOS', 'Android']
- id: mobile
type: boolean
brief: 'A boolean that is true if the browser is running on a mobile device'
note: >
This value is intended to be taken from the
[UA client hints API](https://wicg.github.io/ua-client-hints/#interface)
(`navigator.userAgentData.mobile`). If unavailable, this attribute
SHOULD be left unset.
- id: user_agent
type: string
brief: 'Full user-agent string provided by the browser'
Expand All @@ -40,3 +48,10 @@ groups:
to retrieve brands and platform individually from the User-Agent Client Hints API.
To retrieve the value, the legacy `navigator.userAgent` API can be used.
examples: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'
- id: language
type: string
brief: 'Preferred language of the user using the browser'
note: >
This value is intended to be taken from the Navigator API
`navigator.language`.
examples: ["en", "en-US", "fr", "fr-FR"]
16 changes: 11 additions & 5 deletions specification/resource/semantic_conventions/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ All of these attributes can be provided by the user agent itself in the form of
|---|---|---|---|---|
| `browser.brands` | string[] | Array of brand name and version separated by a space [1] | `[ Not A;Brand 99, Chromium 99, Chrome 99]` | Recommended |
| `browser.platform` | string | The platform on which the browser is running [2] | `Windows`; `macOS`; `Android` | Recommended |
| `browser.user_agent` | string | Full user-agent string provided by the browser [3] | `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36` | Recommended |
| `browser.mobile` | boolean | A boolean that is true if the browser is running on a mobile device [3] | | Recommended |
| `browser.user_agent` | string | Full user-agent string provided by the browser [4] | `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36` | Recommended |
| `browser.language` | string | Preferred language of the user using the browser [5] | `en`; `en-US`; `fr`; `fr-FR` | Recommended |

**[1]:** This value is intended to be taken from the [UA client hints API](https://wicg.github.io/ua-client-hints/#interface) (navigator.userAgentData.brands).
**[1]:** This value is intended to be taken from the [UA client hints API](https://wicg.github.io/ua-client-hints/#interface) (`navigator.userAgentData.brands`).

**[2]:** This value is intended to be taken from the [UA client hints API](https://wicg.github.io/ua-client-hints/#interface) (navigator.userAgentData.platform). If unavailable, the legacy `navigator.platform` API SHOULD NOT be used instead and this attribute SHOULD be left unset in order for the values to be consistent.
The list of possible values is defined in the [W3C User-Agent Client Hints specification](https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform). Note that some (but not all) of these values can overlap with values in the [os.type and os.name attributes](./os.md). However, for consistency, the values in the `browser.platform` attribute should capture the exact value that the user agent provides.
**[2]:** This value is intended to be taken from the [UA client hints API](https://wicg.github.io/ua-client-hints/#interface) (`navigator.userAgentData.platform`). If unavailable, the legacy `navigator.platform` API SHOULD NOT be used instead and this attribute SHOULD be left unset in order for the values to be consistent.
The list of possible values is defined in the [W3C User-Agent Client Hints specification](https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform). Note that some (but not all) of these values can overlap with values in the [`os.type` and `os.name` attributes](./os.md). However, for consistency, the values in the `browser.platform` attribute should capture the exact value that the user agent provides.

**[3]:** The user-agent value SHOULD be provided only from browsers that do not have a mechanism to retrieve brands and platform individually from the User-Agent Client Hints API. To retrieve the value, the legacy `navigator.userAgent` API can be used.
**[3]:** This value is intended to be taken from the [UA client hints API](https://wicg.github.io/ua-client-hints/#interface) (`navigator.userAgentData.mobile`). If unavailable, this attribute SHOULD be left unset.

**[4]:** The user-agent value SHOULD be provided only from browsers that do not have a mechanism to retrieve brands and platform individually from the User-Agent Client Hints API. To retrieve the value, the legacy `navigator.userAgent` API can be used.

**[5]:** This value is intended to be taken from the Navigator API `navigator.language`.
<!-- endsemconv -->

0 comments on commit 6a8fcfa

Please sign in to comment.