Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1146d0e
update exception recording guidelines to not use span events
pellared Jan 7, 2026
1387714
Clarify guidance on capturing exception details in metrics and spans
pellared Jan 7, 2026
f9869db
Add changelog entry
pellared Jan 7, 2026
095f876
Deprecate event.exception and update documentation to use logs for re…
pellared Jan 7, 2026
5a37bb0
Update component designation to 'exceptions' in changelog entry
pellared Jan 7, 2026
353b660
Update .chloggen/3256.yaml
pellared Jan 7, 2026
c16c40c
Apply suggestions from code review
pellared Jan 8, 2026
370ec7c
Update docs/general/recording-errors.md
pellared Jan 12, 2026
a5272a5
Deprecate Semantic conventions for exceptions on spans document
pellared Jan 12, 2026
b340f36
Merge branch 'rem-span-events' of github.com:pellared/semantic-conven…
pellared Jan 12, 2026
f71de5c
revert 'event' to 'log record'
pellared Jan 12, 2026
e8b8f4f
update recording exceptions example
pellared Jan 12, 2026
ac1e486
Update recording-errors.md
pellared Jan 12, 2026
c9cef10
lint
pellared Jan 12, 2026
97b607c
Update .github/copilot-instructions.md
pellared Jan 13, 2026
f3bec71
Update exceptions-spans.md to reference semantic conventions for exce…
pellared Jan 13, 2026
a49a364
Apply suggestion from @lmolkova
pellared Jan 27, 2026
ef4f629
instrumented code -> instrumented operation
pellared Jan 27, 2026
f0d31ea
revert deprecation of Exception event
pellared Jan 27, 2026
e28a464
Clarify error recording guidelines for instrumented operations and ex…
pellared Jan 27, 2026
34508f8
Remove redundant instruction for recording exceptions in the document…
pellared Jan 27, 2026
7519ccd
revert guidance on recording handled exceptions in documentation
pellared Jan 27, 2026
4848c59
Update status link for deprecated exceptions spans documentation
pellared Jan 27, 2026
ec62ed5
Update deprecation note in changelog
pellared Jan 27, 2026
3e0fbbd
add semicolons
pellared Jan 27, 2026
668846f
Merge branch 'rem-span-events' of github.com:pellared/semantic-conven…
pellared Jan 27, 2026
f9e3275
format
pellared Jan 27, 2026
fec7b72
Clarify comments regarding error handling in createIfNotExists method
pellared Jan 27, 2026
14f8c7b
Clarify comments on span status handling for ResourceAlreadyExistsExc…
pellared Jan 27, 2026
ee0ba3e
format
pellared Jan 27, 2026
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
22 changes: 22 additions & 0 deletions .chloggen/3256.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.
#
# If your change doesn't affect end users you should instead start
# your pull request title with [chore] or use the "Skip Changelog" label.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement
Comment thread
pellared marked this conversation as resolved.
Outdated

# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
component: exceptions

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Update exception recording guidelines to not use span events.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
# The values here must be integers.
issues: [3256]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ these requirements:

- **Spans**: Set status to Error, populate `error.type`, set description when helpful
- **Metrics**: Include `error.type` attribute for filtering and analysis
- **Exceptions**: Record as span events or log records using SDK APIs
- **Exceptions**: Record as log records
Comment thread
pellared marked this conversation as resolved.
- **Consistency**: Same `error.type` across spans and metrics for same operation

## Common Issues to Flag
Expand Down
2 changes: 1 addition & 1 deletion docs/exceptions/exceptions-spans.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exceptions associated with spans.
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

**Status:** ![Stable](https://img.shields.io/badge/-stable-lightgreen)
**Status:** ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Use logs to record exceptions instead.
Comment thread
pellared marked this conversation as resolved.
Outdated

The event name MUST be `exception`.

Expand Down
31 changes: 18 additions & 13 deletions docs/general/recording-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ include it if the operation succeeded.

## Recording exceptions

When an instrumented operation fails with an exception, instrumentation SHOULD record
this exception as a [span event](/docs/exceptions/exceptions-spans.md) or a [log record](/docs/exceptions/exceptions-logs.md).
When an instrumented operation throws an exception, instrumentation SHOULD
Comment thread
pellared marked this conversation as resolved.
Outdated
Comment thread
pellared marked this conversation as resolved.
Outdated
record this exception as a [log record](/docs/exceptions/exceptions-logs.md).
Comment thread
pellared marked this conversation as resolved.
Outdated

It's RECOMMENDED to use the `Span.recordException` API or logging library API that takes exception instance
instead of providing individual attributes. This enables the OpenTelemetry SDK to
control what information is recorded based on application configuration.
When the instrumented operation has not succeeded due to an exception,
refer to the [recording errors on spans](#recording-errors-on-spans)
and to the [recording errors on metrics](#recording-errors-on-metrics)
on capturing exception details on these signals.

It's NOT RECOMMENDED to record the same exception more than once.

It's NOT RECOMMENDED to record exceptions that are handled by the instrumented library.
Comment thread
pellared marked this conversation as resolved.

For example, in this code-snippet, `ResourceAlreadyExistsException` is handled and the corresponding
Expand All @@ -100,22 +102,25 @@ to the caller should be recorded (or logged) once.
```java
public boolean createIfNotExists(String resourceId) throws IOException {
Comment thread
pellared marked this conversation as resolved.
Span span = startSpan();
long startTime = System.nanoTime();
try {
create(resourceId);
recordMetric("acme.resource.create.duration", System.nanoTime() - startTime);
return true;
} catch (ResourceAlreadyExistsException e) {
// not recording exception and not setting span status to error - exception is handled
// but we can set attributes that capture additional details
// not setting span status to error - as the exception is not an error
// but we still log and set attributes that capture additional details
logger.debug(e);
Comment thread
pellared marked this conversation as resolved.
Outdated
span.setAttribute(AttributeKey.stringKey("acme.resource.create.status"), "already_exists");
recordMetric("acme.resource.create.duration", System.nanoTime() - startTime);
Comment thread
lmolkova marked this conversation as resolved.
return false;
} catch (IOException e) {
// recording exception here (assuming it was not recorded inside `create` method)
span.recordException(e);
// or
// logger.warn(e);

span.setAttribute(AttributeKey.stringKey("error.type"), e.getClass().getCanonicalName())
logger.error(e);
Comment thread
pellared marked this conversation as resolved.
Outdated
String errorType = e.getClass().getCanonicalName();
Comment thread
pellared marked this conversation as resolved.
span.setAttribute(AttributeKey.stringKey("error.type"), errorType);
span.setStatus(StatusCode.ERROR, e.getMessage());
Comment thread
pellared marked this conversation as resolved.
recordMetric("acme.resource.create.duration", System.nanoTime() - startTime,
AttributeKey.stringKey("error.type"), errorType);
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ groups:
- id: event.exception
name: exception
stability: stable
deprecated:
reason: obsoleted
note: Use logs to record exceptions instead.
Comment thread
pellared marked this conversation as resolved.
Outdated
Comment thread
pellared marked this conversation as resolved.
Outdated
type: event
brief: >
This event describes a single exception.
Expand Down
Loading