fix(logs): optimize LogRecord memory by removing redundant context by ajuijas · Pull Request #4977 · open-telemetry/opentelemetry-python

@ajuijas

Removed direct storage of the Context object in LogRecord to prevent
memory inflation when logs are buffered. Correlation IDs (TraceId,
SpanId, TraceFlags) are still preserved.

Resolves open-telemetry#4957

@lzchen

…etry#4957)

Clear LogRecord context references before buffering in the SDK to prevent memory inflation while maintaining context access for synchronous processors.
…ntext"

This reverts commit c77ecd0.

xrmx

xrmx approved these changes Mar 17, 2026

@xrmx xrmx mentioned this pull request

Mar 17, 2026

@xrmx

xrmx

…/__init__.py

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>

@lzchen

lzchen

@lzchen

@ajuijas

- Add missing Context import.
- Apply memory optimization to SimpleLogRecordProcessor.
- Update BatchLogRecordProcessor to use Context() instead of None.

tammy-baylis-swi