Skip to content
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- `opentelemetry-sdk`: Optimize `LogRecord` memory in `BatchLogRecordProcessor` by clearing the `Context` object before buffering.
([#4957](https://github.com/open-telemetry/opentelemetry-python/issues/4957))
- `opentelemetry-sdk`: Add file configuration support with YAML/JSON loading, environment variable substitution, and schema validation against the vendored OTel config JSON schema
([#4898](https://github.com/open-telemetry/opentelemetry-python/pull/4898))
- Fix intermittent CI failures in `getting-started` and `tracecontext` jobs caused by GitHub git CDN SHA propagation lag by installing contrib packages from the already-checked-out local copy instead of a second git clone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from __future__ import annotations

import abc
import copy
import enum
import logging
import sys
Expand Down Expand Up @@ -286,8 +287,13 @@ def on_emit(self, log_record: ReadWriteLogRecord) -> None:
if log_record.resource is not None
else Resource.create({})
)
# Shallow copy the API log record to break the reference to the potentially large context
# while keeping the original context intact for other processors.
api_log_record = copy.copy(log_record.log_record)
api_log_record.context = Context()

readable_log_record = ReadableLogRecord(
log_record=log_record.log_record,
log_record=api_log_record,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make this change for SimpleLogRecordProcessor as well?

resource=resource,
instrumentation_scope=log_record.instrumentation_scope,
limits=log_record.limits,
Expand Down