Skip to content

Commit

Permalink
Refactoring: move browser to the registry (open-telemetry#605)
Browse files Browse the repository at this point in the history
Co-authored-by: Joao Grassi <joao.grassi@dynatrace.com>
  • Loading branch information
2 people authored and pyohannes committed Jan 17, 2024
1 parent 0ac3a50 commit 86aaea5
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 44 deletions.
1 change: 1 addition & 0 deletions docs/attributes-registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ All registered attributes are listed by namespace in this registry.
Currently, the following namespaces exist:

* [Browser](browser.md)
* [Client](client.md)
* [Cloud](cloud.md)
* [Code](code.md)
Expand Down
24 changes: 24 additions & 0 deletions docs/attributes-registry/browser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--- Hugo front matter used to generate the website version of this page:
--->

# Browser

## Browser Attributes

<!-- semconv registry.browser(omit_requirement_level) -->
| Attribute | Type | Description | Examples |
|---|---|---|---|
| `browser.brands` | string[] | Array of brand name and version separated by a space [1] | `[ Not A;Brand 99, Chromium 99, Chrome 99]` |
| `browser.language` | string | Preferred language of the user using the browser [2] | `en`; `en-US`; `fr`; `fr-FR` |
| `browser.mobile` | boolean | A boolean that is true if the browser is running on a mobile device [3] | |
| `browser.platform` | string | The platform on which the browser is running [4] | `Windows`; `macOS`; `Android` |

**[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 Navigator API `navigator.language`.

**[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]:** 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.
<!-- endsemconv -->
8 changes: 4 additions & 4 deletions docs/resource/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ All of these attributes can be provided by the user agent itself in the form of
<!-- semconv browser -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| `browser.brands` | string[] | Array of brand name and version separated by a space [1] | `[ Not A;Brand 99, Chromium 99, Chrome 99]` | Recommended |
| `browser.language` | string | Preferred language of the user using the browser [2] | `en`; `en-US`; `fr`; `fr-FR` | Recommended |
| `browser.mobile` | boolean | A boolean that is true if the browser is running on a mobile device [3] | | Recommended |
| `browser.platform` | string | The platform on which the browser is running [4] | `Windows`; `macOS`; `Android` | Recommended |
| [`browser.brands`](../attributes-registry/browser.md) | string[] | Array of brand name and version separated by a space [1] | `[ Not A;Brand 99, Chromium 99, Chrome 99]` | Recommended |
| [`browser.language`](../attributes-registry/browser.md) | string | Preferred language of the user using the browser [2] | `en`; `en-US`; `fr`; `fr-FR` | Recommended |
| [`browser.mobile`](../attributes-registry/browser.md) | boolean | A boolean that is true if the browser is running on a mobile device [3] | | Recommended |
| [`browser.platform`](../attributes-registry/browser.md) | string | The platform on which the browser is running [4] | `Windows`; `macOS`; `Android` | Recommended |
| [`user_agent.original`](../attributes-registry/user-agent.md) | string | Full user-agent string provided by the browser [5] | `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 |

**[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`).
Expand Down
47 changes: 47 additions & 0 deletions model/registry/browser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
groups:
- id: registry.browser
prefix: browser
type: resource
brief: >
The web browser attributes
attributes:
- id: brands
type: string[]
brief: 'Array of brand name and version separated by a space'
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`).
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.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.
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: 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"]
44 changes: 4 additions & 40 deletions model/resource/browser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,10 @@ groups:
The `browser.*` attributes MUST be used only for resources that represent applications
running in a web browser (regardless of whether running on a mobile or desktop device).
attributes:
- id: brands
type: string[]
brief: 'Array of brand name and version separated by a space'
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`).
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.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.
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: 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"]
- ref: browser.brands
- ref: browser.platform
- ref: browser.mobile
- ref: browser.language
- ref: user_agent.original
brief: 'Full user-agent string provided by the browser'
note: >
Expand Down

0 comments on commit 86aaea5

Please sign in to comment.