Skip to content

Update recording errors doc - document when to use error, exception (or both) attributes #2296

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

lmolkova
Copy link
Contributor

Fixes #2001

Updates errors guidance to cover:

  • errors vs exceptions and when to use which set of attributes
  • reporting errors on logs/events
  • reporting error.message attribute


- *Error* refers to a general concept describing any non-success condition. This may include an, non-success status code, or an invalid response.

- *Exception* specifically refers to runtime exceptions and their associated stack traces.
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this mesh with languages that don't have "exceptions" and actually only have "errors" like Go or Rust?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored it slightly, please take a look, the key change:

added

Errors and exceptions are related but not the same: an error can occur without
an exception being thrown, and an exception does not necessarily constitute an
error.

Exceptions and how they are recorded in telemetry are inherently
language-specific. Some languages, such as Rust or Go, do not use exceptions
at all.

This document focuses on recording errors.

Plus there are a couple of points below that should address it

  • Semantic conventions intended for cross-language applicability SHOULD use
    error.* attributes.

  • exception attributes SHOULD be documented for conventions that target
    exceptions directly such as exception events.

@lmolkova lmolkova force-pushed the errors-message-and-guidance-for-logs branch from 2ec5940 to 1dc9015 Compare May 23, 2025 17:48
@lmolkova
Copy link
Contributor Author

lmolkova commented Jun 8, 2025

@smaddock could you please leave specific suggestions on the content modified by this PR?

WRT

Deprecate the existing exception domain and its attributes

There is no active discussion on this - I'd suggest to start with an issue in the https://github.com/open-telemetry/opentelemetry-specification. You also probably want to read open-telemetry/opentelemetry-specification#4333

- Semantic conventions intended for cross-language applicability SHOULD use
`error.*` attributes.

- `exception` attributes SHOULD be documented for conventions that target
Copy link
Contributor Author

@lmolkova lmolkova Jun 9, 2025

Choose a reason for hiding this comment

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

this maybe a breaking(?) change for go/rust/no-exception languages

@trask trask added this to Logs SIG Jun 24, 2025
@trask trask moved this to In progress in Logs SIG Jun 24, 2025
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jun 25, 2025
@lmolkova lmolkova requested a review from Copilot July 1, 2025 05:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the error guidance by clarifying when to use error versus exception attributes, adds logging/event recommendations, and updates examples to ensure proper error reporting.

  • Defines “Error vs exception” and when both attribute sets apply
  • Adds “Recording errors on logs and events” section
  • Updates example snippets and cross-links to the general error guidance

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
model/error/registry.yaml Added link to the general recording-errors documentation
docs/registry/attributes/error.md Linked to the new recording-errors guide
docs/general/recording-errors.md Introduced Error vs exception section, log/event guidance, warnings, and updated examples
.chloggen/2296.yaml Updated changelog metadata
Comments suppressed due to low confidence (3)

docs/general/recording-errors.md:57

  • Consider capitalizing the first word of this bullet to match the style of other list items (e.g., change “when” to “When”).
- when the error and exception details are identical, and both sets

docs/general/recording-errors.md:170

  • The blank > line after the warning header may break the admonition rendering. Removing this blank line will ensure the warning block displays correctly.
>

docs/general/recording-errors.md:210

  • Align the finally brace indentation with the catch block for consistent formatting (e.g., match the indentation level of the closing } of the catch).
  } finally {

@github-actions github-actions bot removed the Stale label Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

When to use error vs exception attributes
3 participants