diff --git a/CHANGELOG.md b/CHANGELOG.md index 121ac65f215..319ea041152 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/semantic_conventions/resource/browser.yaml b/semantic_conventions/resource/browser.yaml index 70996be8f7c..53493b82ff0 100644 --- a/semantic_conventions/resource/browser.yaml +++ b/semantic_conventions/resource/browser.yaml @@ -13,7 +13,7 @@ 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 @@ -21,17 +21,25 @@ 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.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' @@ -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"] diff --git a/specification/resource/semantic_conventions/browser.md b/specification/resource/semantic_conventions/browser.md index ca720c99a48..b00e416c997 100644 --- a/specification/resource/semantic_conventions/browser.md +++ b/specification/resource/semantic_conventions/browser.md @@ -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`.