Skip to content

Add optional Exception parameter to Emit LogRecord#4824

Merged
lmolkova merged 10 commits intoopen-telemetry:mainfrom
trask:log-record-exception
Jan 23, 2026
Merged

Add optional Exception parameter to Emit LogRecord#4824
lmolkova merged 10 commits intoopen-telemetry:mainfrom
trask:log-record-exception

Conversation

@trask
Copy link
Member

@trask trask commented Jan 7, 2026

Part of OTEP 4430.

This could be considered "just a convenience", but (in addition to a very nice convenience) it also unlocks two additional features:

Prototype: open-telemetry/opentelemetry-java#7182

@trask trask force-pushed the log-record-exception branch from 5c36fd4 to 7f8e5ee Compare January 7, 2026 21:37
@trask trask marked this pull request as ready for review January 7, 2026 22:09
@trask trask requested review from a team as code owners January 7, 2026 22:09
Co-authored-by: Robert Pająk <pellared@hotmail.com>
@cijothomas
Copy link
Member

Performance optimization since the SDK can take OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT into consideration when generating large exception.stacktrace attributes

Can you add some details how this helps with perf? if we didn't have exception in emit_log_record(...), user would likely be using log_record.set_attribute(exception.stacktrace), at which point the set_attribute implementation in SDK can store only upto the limits right?

pellared
pellared previously approved these changes Jan 8, 2026
@trask
Copy link
Member Author

trask commented Jan 8, 2026

user would likely be using log_record.set_attribute(exception.stacktrace)

yup, and user would have to generate the entire stacktrace, only for it to be truncated to X chars

in Java (open-telemetry/opentelemetry-java#7281) we only generate the first X chars of the stacktrace in the firstplace

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

LGTM, nice improvement!
(Exception is already first class in .NET's ILogger logging library - every log method can accept an Exception optionally.)

@pellared pellared dismissed their stale review January 8, 2026 18:43

one question

@carlosalberto
Copy link
Contributor

Performance optimization since the SDK can take OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT into consideration when generating large exception.stacktrace attributes (a very real issue in the Java world: open-telemetry/opentelemetry-java#7281)

I'm wondering whether a note could be added - such optimizations are optional but it would be nice to leave a hint to people reading the spec in the future.

trask and others added 2 commits January 14, 2026 09:52
@trask
Copy link
Member Author

trask commented Jan 20, 2026

Performance optimization since the SDK can take OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT into consideration when generating large exception.stacktrace attributes (a very real issue in the Java world: open-telemetry/opentelemetry-java#7281)

I'm wondering whether a note could be added - such optimizations are optional but it would be nice to leave a hint to people reading the spec in the future.

added in 63e791c

@lmolkova lmolkova added this pull request to the merge queue Jan 23, 2026
Merged via the queue into open-telemetry:main with commit e0a5864 Jan 23, 2026
8 checks passed
@lmolkova lmolkova deleted the log-record-exception branch January 23, 2026 19:18
@carlosalberto carlosalberto mentioned this pull request Feb 11, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 13, 2026
### Context

- Deprecate Jaeger propagator and make propagator implementation
optional.

([#4827](#4827))
- Deprecate OT Trace propagator and make propagator implementation
optional.

([#4851](#4851))

### Metrics

- Add normative language to the Metrics API/SDK spec concurrency
requirements.

([#4868](#4868))

### Logs

- Add optional `Exception` parameter to Emit LogRecord.

([#4824](#4824))
- Add normative language to the Logging API/SDK spec concurrency
requirements.

([#4885](#4885))

### Resource

- Refine the handling of OTEL_RESOURCE_ATTRIBUTES.

([#4856](#4856))

### Common

- Add string representation guidance for complex attribute value types
(byte arrays,
  empty values, arrays, and maps) for non-OTLP protocols.

([#4848](#4848))

### Compatibility

- Stabilize Prometheus Counter to OTLP Sum transformation.

([#4862](#4862))
- Stabilize Prometheus Gauge to OTLP Gauge transformation.

([#4871](#4871))

### SDK Configuration

- Swap Tracer/Meter/LoggerConfig `disabled` for `enabled` to avoid
double negatives

([#4823](#4823))
- Declarative configuration: rename `ComponentProvider` to
`PluginComponentProvider`, `CreatePlugin` to `CreateComponent` in effort
to
  use consistent vocabulary

([#4806](#4806))
- Declarative configuration: Update instrumentation config behavior to
return
  empty object when not set

([#4817](#4817))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants