open-telemetry / open-telemetry/opentelemetry-ruby

Support an `exception:` param on `Logger#on_emit with semconv attribute bridging

Open
#2,349 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement logs spec-compliance spec:stable
Dominant language
Ruby
Stars
606
Forks
301
Avg merge
3d 19h
Merged PRs (30d)
42

Description

Spec requirement

The API MAY accept an optional Exception parameter (api.md:127-129 (permalink)); if provided, the SDK MUST by default set attributes from the exception per the exception semantic conventions, and user-provided attributes MUST take precedence and MUST NOT be overwritten (sdk.md:233-237 (permalink)); any such attributes MUST follow the OTel exception-attribute semantic conventions (data-model.md:442-443 (permalink)).

Current behavior

No exception: parameter exists on either Logger#on_emit method (API: logs_api/lib/opentelemetry/logs/logger.rb:44-56 (permalink); SDK: logs_sdk/lib/opentelemetry/sdk/logs/logger.rb:66-76 (permalink)) — there is no code path for exception-derived attributes.

Suggested fix

Add an exception: keyword arg to both on_emit methods. In the SDK, before finalizing LogRecord attributes, merge semconv exception.* attributes derived from the exception, without overwriting any attribute the caller already supplied.

Related rows in SPEC_COMPLIANCE_LOGS.md

API-10, SDK-21, DM-5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with logs_api/lib/opentelemetry/logs/logger.rb:44-56 and logs_sdk/lib/opentelemetry/sdk/logs/logger.rb:66-76, then compare the referenced API, SDK, and data-model specification sections. Verify the existing logs tests and SPEC_COMPLIANCE_LOGS.md entries API-10, SDK-21, and DM-5. Done means both methods accept exception:, exception attributes follow the semantic conventions, and caller attributes take precedence.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend-api-design, observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.