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 Exception Event #1942

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
41 changes: 41 additions & 0 deletions docs/browser/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--- 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.

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

This event describes an error or exception that occurs in a browser application.

**Body fields:**

| Body Field | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `column_number` | int | Column number where the error occurred. | `5` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `file_name` | string | Name of the file that generated the error. | `foo.js` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `line_number` | int | Line number where the error occurred. | `3` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `message` | string | The exception message. | `Can't convert 'int' object to str implicitly` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `stacktrace` | string | A stacktrace as a string in the natural representation for the language runtime. The representation is to be determined and documented by each language SIG. | `Exception in thread main java.lang.RuntimeException: Test exception at com.example.GenerateTrace.methodB(GenerateTrace.java:13)` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| `type` | string | The type of the exception (its fully-qualified class name, if applicable). The dynamic type of the exception should be preferred over the static type in languages that support it. | `TypeError`; `java.net.ConnectException`; `OSError` | `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
54 changes: 54 additions & 0 deletions model/browser/events.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
groups:
- id: event.browser.exception
Copy link
Contributor

@breedx-splk breedx-splk Mar 4, 2025

Choose a reason for hiding this comment

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

Similar to comments I left on #1941, I think other client instrumentation would benefit from also having these relaxed to be non-browser. Alternatives: rum.exception, client.exception, app.exception, runtime.exception.....

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think if we can defined a "standard" exception event would be a better approach (things have evolved quite a bit since we originally defined this).
Even if this also means that as part of a "standard" exception event it would define and use the top-level
exception.* attributes, but this may also mean that we should define an exception "source" to make life a little easier when attempting to directly compare values

-- community thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Karlie-777 can you please review open-telemetry/opentelemetry-js-contrib#2751 which is an initial implementation of a browser "event" which is using the existing top-level 3 attributes.

stability: development
type: event
name: browser.exception
brief: >
This event describes an error or exception that occurs in a browser application.
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets also "add" a top-level attribute url.full (redacted) or include a cutdown url within the data), as while having the "filename" is useful, we should also be including the "hosting" page as the source file (bundle) may throw at different locations and for different reasons when used from different pages / scenarios.

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.exception
requirement_level: required
stability: development
type: map
fields:
- id: file_name
type: string
stability: development
brief: Name of the file that generated the error.
requirement_level: recommended
examples: ["foo.js"]
- id: line_number
type: int
stability: development
brief: Line number where the error occurred.
requirement_level: recommended
examples: [3]
- id: column_number
type: int
stability: development
brief: Column number where the error occurred.
requirement_level: recommended
examples: [5]
- id: message
type: string
stability: development
brief: The exception message.
requirement_level: recommended
examples: ["Can't convert 'int' object to str implicitly"]
- id: stacktrace
type: string
stability: development
brief: >
A stacktrace as a string in the natural representation for the language runtime.
The representation is to be determined and documented by each language SIG.
requirement_level: recommended
examples: ["Exception in thread main java.lang.RuntimeException:
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 the examples to make the generated table look nicer

Test exception at com.example.GenerateTrace.methodB(GenerateTrace.java:13)"]
- id: type
type: string
stability: development
brief: >
The type of the exception (its fully-qualified class name, if applicable).
The dynamic type of the exception should be preferred over the static type in languages that support it.
requirement_level: recommended
examples: ["TypeError", "java.net.ConnectException", "OSError"]