Repository navigation
fix: forward Rust session log tags to Python log records - #384
Open
AlexTranAmz wants to merge 2 commits into
Open
AlexTranAmz wants to merge 2 commits into
AlexTranAmz wants to merge 2 commits into
Conversation
The openjd-sessions crate tags every record its session_log! macro emits with session_id, openjd_log_content and openjd_timestamp_usec as log key-values. The bindings installed pyo3-log without its kv feature, so those key-values never reached the Python LogRecord: consumers could not tell which session a Rust record belonged to, or what kind of content it carried, and routed or dropped the records accordingly. Enable pyo3-log's kv feature (available since 0.13.1) so the three fields are passed to Logger.makeRecord as extra attributes. pyo3-log renders key-values as strings, so openjd_log_content and openjd_timestamp_usec arrive as decimal strings; the openjd.sessions._v1 wrapper converts them back to LogContent and int for consumers. Document the attributes in the sessions interface spec and drop the stale comment that claimed a logger-target remap which never existed. The test runs one real session in a child interpreter and asserts every record that carries openjd_log_content also carries session_id and the timestamp, with the documented bit values. Signed-off-by: AlexTranAmz <167144297+AlexTranAmz@users.noreply.github.com>
|
Claude review · advisory Reviewed Open: 0 blocking · 0 should-fix · 0 nit. ✅ Nothing blocking. Fix or reply to each thread; the next revision's review re-checks open threads and resolves those it agrees are handled. Resolving a thread yourself also closes it. Later revisions review only what changed. |
Contributor
|
We will need something similiar to aws-deadline/deadline-cloud-worker-agent#1130 to remove Python 3.9 from our actions before we can merge |
jericht
approved these changes
Nov 6, 2026
Signed-off-by: AlexTranAmz <167144297+AlexTranAmz@users.noreply.github.com>
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.
Fixes: N/A
What was the problem/requirement? (What/Why)
The
openjd-sessionscrate tags every record itssession_log!macro emits with threelogkey-values:session_id,openjd_log_content(theLogContentbitmask) andopenjd_timestamp_usec. The bindings installpyo3-logwithout itskvfeature (rust-bindings/Cargo.toml), so those key-values are dropped before the PythonLogRecordis built. Consumers of theopenjd.sessionslogger cannot tell which session a Rust-emitted record belongs to or what kind of content it carries. In the Deadline Cloud Worker Agent this means Rust session lines never reach the worker log, lines from concurrent sessions are not kept apart, and the job-attachments output-manifest lines are not picked up.What was the solution? (How)
rust-bindings/Cargo.toml:pyo3-log = { version = "0.13.1", features = ["kv"] }. Thekvfeature first shipped in pyo3-log 0.13.1 (Cargo.lockalready resolves 0.13.4 and is unchanged). With it, pyo3-log passes each key-value as anextraattribute toLogger.makeRecord.rust-bindings/src/lib.rs: comment-only; the old comment described a logger-target remap that never existed (openjd-rs already logs to theopenjd.sessionstarget).specs/python-sessions-interface.md: documents the three attributes. pyo3-log renders key-values as strings, soopenjd_log_contentandopenjd_timestamp_usecarrive as decimal strings; theopenjd.sessions._v1wrapper (openjd-sessions-for-python) converts them back toLogContentandint. That companion change is a separate PR in that repository.What is the impact of this change?
Records emitted by the Rust session runtime carry
session_id(str),openjd_log_content(str of the bitmask) andopenjd_timestamp_usec(str) asLogRecordattributes. Records that already carried nothing are unaffected. No Python API changes.How was this change tested?
See DEVELOPMENT.md for information on running tests.
New
test/openjd/sessions/test_logging.pyruns one realopenjd._openjd_rs.Sessiontask in a child interpreter (pyo3-log caches each logger's level on first use, so the child setsopenjd.sessionsto INFO before importing the extension) and asserts that every record carryingopenjd_log_contentalso carriessession_idandopenjd_timestamp_usec, thatopenjd_log_contentis within the documented bit values, and that everysession_idnames the test's session. Against the unchanged build the test fails with "no record carried session_id".Local results (Linux, this branch):
hatch run teston Python 3.9, 3.10, 3.11, 3.12: 6331 passed, 26 skipped, 5 xfailed each; coverage 94.2-94.3% (gate 94%)hatch run lint,hatch run typing: clean on all fourcargo build/clippy/test --all-targets --lockedandcargo test --doconrust-bindings: clean;cargo fmt --checkcleansys.executable -cso it does not depend on a shell.Was this change documented?
specs/python-sessions-interface.mdlogging section and thelib.rscomment.Is this a breaking change?
No. Three new attributes appear on records that the Rust runtime emits; no existing attribute or signature changes.
Does this change impact security?
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.