Repository navigation
Keep ReplaySafeLoggerProvider working with opentelemetry-api 1.45 - #2030
Merged
tconley1428 merged 3 commits intoOct 28, 2026
Merged
Conversation
Contributor
|
Seems reasonable, but we need a CLA signature. |
|
|
Contributor
Author
|
Signed the CLA, and |
tconley1428
approved these changes
Oct 28, 2026
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.
With opentelemetry-api 1.45,
ReplaySafeLoggerProvider.get_logger()raisesTypeError: Can't instantiate abstract class _ReplaySafeLogger without an implementation for abstract method 'enabled'. Uncaught inside a workflow, that fails the workflow task on every attempt by default. 1.45.0 addedLogger.enabledas an abstract method, and_ReplaySafeLoggerdoesn't implement it.The
opentelemetryextra allowsopentelemetry-api>=1.26,<2, and a freshuv pip install "temporalio[opentelemetry]==1.34.0"resolved 1.45.1 on October 28. This repo's lock pins 1.42.1, and the October 27test-latest-depsrun also installed 1.42.1, sotest_wrapper_abc_drift.pydidn't exercise the new method in that run.This change adds
enabled()to_ReplaySafeLogger. While the workflow is replaying history events it returnsFalse, the same checkemit()uses, since callers checkenabled()to skip building a record. Otherwise it delegates to the wrapped logger when the logger hasenabled(), and returnsTruewhen it doesn't, as with loggers from an API before 1.45, so a caller that checkshasattrfirst doesn't hitAttributeError.Four tests in
tests/contrib/opentelemetry/test_logger_provider.pycover delegation outside a workflow,Falseduring replay, delegation in the state a query or update validator sees during replay (simulated like the existing tests), and a wrapped logger withoutenabled(). Run againstmainwith 1.42.1, the replay test, whose test logger implementsenabled(), fails withassert not True, because__getattr__forwards the call even during replay.With 1.45.1, a workflow that emits one log record through
ReplaySafeLoggerProviderfails every workflow task with theTypeErrorabove onmain, and completes with this change, exporting the record.1.45 also removed
opentelemetry.util.types._ExtendedAttributes, which these files import. That breaks type checks and this test module on 1.45, and needs a choice of annotation, so it's in #2029.Validation, with Python 3.12 and the Rust bridge of the temporalio 1.34.0 wheel:
test_logger_provider.pyandtest_wrapper_abc_drift.pypass with opentelemetry-api 1.42.1 and 1.43.0 (22 tests), andtest_wrapper_abc_drift.pypasses with 1.45.1.check --select I,format --check), pyright 1.1.403, basedpyright 1.34.0 and mypy pass on the changed files with 1.42.1 and 1.43.0, and pydocstyle passes on the changed source file.