Repository navigation
Clean up logs API, SDK, and TestBase utilities before logs stabilization - #5934
Open
DylanRussell wants to merge 6 commits into
Open
DylanRussell wants to merge 6 commits into
DylanRussell wants to merge 6 commits into
Conversation
Pull request dashboard statusWaiting on the author · refreshed 2026-11-13 20:48 UTC Investigate required status check failures. Status above doesn't look right?
|
DylanRussell
force-pushed
the
logs-pre-stabilization-cleanups
branch
2 times, most recently
from
November 13, 2026 15:43
7447822 to
e34f88a
Compare
DylanRussell
force-pushed
the
logs-pre-stabilization-cleanups
branch
from
November 13, 2026 15:54
e34f88a to
ba7a508
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Executor shutdown leaves later processor calls submitting to a closed pool and raising RuntimeError, including during Python logging shutdown, so shutdown-state checks synchronized with submissions are needed.
1 open issue
What changed in this PR
Prepares OpenTelemetry Python logging for stabilization by aligning API signatures, improving SDK record handling and cleanup, and extending shared test utilities.
Changes:
- Aligns
get_loggerparameters withLoggerProvider.get_loggerand removes unnecessaryLogRecordinheritance. - Updates JSON serialization, executor shutdown, and queued exception-reference cleanup.
- Adds logging helpers to
TestBase, regression tests, and changelog entries.
| File | Description |
|---|---|
tests/opentelemetry-test-utils/tests/test_base.py |
Tests log capture through TestBase. |
tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py |
Adds logging setup, global resets, and capture helpers. |
opentelemetry-sdk/tests/logs/test_multi_log_processor.py |
Tests executor shutdown. |
opentelemetry-sdk/tests/logs/test_log_record.py |
Tests scope serialization and nullable observed timestamps. |
opentelemetry-sdk/tests/logs/test_export.py |
Tests clearing copied exception references without modifying originals. |
opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py |
Clears exception references before batch queueing. |
opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py |
Updates JSON output and closes the concurrent processor’s executor. |
opentelemetry-api/tests/logs/test_logger_provider.py |
Tests logger arguments and defaults. |
opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py |
Aligns logger parameters and simplifies LogRecord inheritance. |
.changelog/5934.fixed |
Documents SDK fixes and logging test helpers. |
.changelog/5934.changed |
Documents breaking API changes. |
Review effort: Balanced
aabmass
reviewed
Nov 13, 2026
…tiLogRecordProcessor after shutdown
aabmass
reviewed
Nov 13, 2026
herin049
approved these changes
Nov 13, 2026
Open
6 tasks done
herin049
approved these changes
Nov 13, 2026
Contributor
Author
|
Will need open-telemetry/opentelemetry-python-contrib#5337 to go in first in order to get a passing CI |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Make some changes ahead of stabilization:
opentelemetry-api(get_logger,LoggerProvider.get_logger&LogRecord):get_loggerwithLoggerProvider.get_loggerand make optional arguments keyword-only (*): Renameinstrumenting_module_name: strandinstrumenting_library_version: str = ""toname: strandversion: str | None = None, movelogger_providerto the end ofget_logger, and make optional arguments (version,schema_url,attributes,logger_provider) keyword-only (*) on bothget_loggerandLoggerProvider.get_logger(matchingLogRecord.__init__,Logger.emit, andLogger.enabled). Previously,get_logger(name=...)raisedTypeError, and omittingversionsetInstrumentationScope.version = ""instead ofNone(missing theLoggerProvidercache).ABCinheritance fromLogRecord:LogRecordhas no abstract methods and is instantiated directly.opentelemetry-sdk(ReadableLogRecord& Processors):"instrumentation_scope"inReadableLogRecord.to_json().self._executor.shutdown()inConcurrentMultiLogRecordProcessor.shutdown()after shutting down child processors so theThreadPoolExecutoris not leaked, and guard post-shutdown calls (on_emit,force_flush,enabled,shutdown).api_log_record.exception = Nonealongsideapi_log_record.context = Context()on the shallow-copiedLogRecordinBatchLogRecordProcessor.on_emit()so exception__traceback__frames are not retained in memory while records sit in the batch queue (exception attributes are already extracted duringLogger.emit()).opentelemetry-test-utils(TestBase):create_logger_provider,self.logger_provider,self.memory_log_exporter, andget_finished_logs()toTestBase, and reset logging globals insetUp/tearDownalongside traces and metrics.Requires companion contrib PR: open-telemetry/opentelemetry-python-contrib#5337