Skip to content

Implement Tracing Integration#10

Merged
dylanbstorey merged 26 commits intodylanbstorey:mainfrom
LockedThread:feat/impl-tracing
Jul 4, 2025
Merged

Implement Tracing Integration#10
dylanbstorey merged 26 commits intodylanbstorey:mainfrom
LockedThread:feat/impl-tracing

Conversation

@LockedThread
Copy link
Copy Markdown
Contributor

Overview

The new feature bridges Python logging with Rust’s tracing ecosystem, allowing for enhanced diagnostics and a unified logging interface across both languages. This addition is especially useful for projects that rely on structured logging and require detailed, contextual log output for debugging complex issues.

Key Changes

  • Tracing Implementation:
    Integrated a new tracing backend that captures and forwards log events from Python into Rust’s tracing framework. This includes mapping Python log levels to their corresponding tracing levels for consistency. Additionally, I added support for KV pairs via Json serialization.

  • Code Modifications:

    • Updated the logging initialization code to support the new tracing functionality.
    • Introduced conditional feature flags to enable or disable tracing support.
    • Adjusted existing logger configuration to ensure seamless integration without disrupting current functionality.
  • Documentation & Examples:
    Updated README and inline documentation to cover the usage of the new tracing feature. Examples have been added to demonstrate how to configure and use the tracing integration effectively.

Example code

  • A new example is included to show proper usage of tracing with KV support.

Disclaimer

Impact and Future Work

  • Backward Compatibility:
    Existing users of pyo3-pylogger will experience no changes unless they opt-in to the new tracing functionality. However, we had to increase the minimum support pyo3 version to 0.23 to include serde-pyobject. This must be at least a minor version update.

Maintain DRAFT status until Jij-Inc/serde-pyobject#21 is merged.

Your feedback is welcome, and I look forward to discussing any improvements or adjustments needed for this feature.

Please review and let me know if there are any questions or additional test cases that should be considered.

LockedThread and others added 25 commits March 30, 2025 19:05
@dylanbstorey
Copy link
Copy Markdown
Owner

Looks ok to me, going to ask we hold off on the merge until upstream changes get merged in just to make sure dependencies are stable.

@dylanbstorey
Copy link
Copy Markdown
Owner

Also - go ahead and do a bump to 0.5 on your PR.

@LockedThread
Copy link
Copy Markdown
Contributor Author

Looks ok to me, going to ask we hold off on the merge until upstream changes get merged in just to make sure dependencies are stable.

Agreed.

@dylanbstorey
Copy link
Copy Markdown
Owner

@LockedThread - i’m afraid that upstream PR isn’t going anywhere. Someone mentioned pythonize as a potential workaround for serde-pyobject. Have you looked at it ?

@LockedThread
Copy link
Copy Markdown
Contributor Author

@LockedThread - i’m afraid that upstream PR isn’t going anywhere. Someone mentioned pythonize as a potential workaround for serde-pyobject. Have you looked at it ?

😞 Unfortunately yeah. I have been using that PR'd version in production for months without issue. I currently do not have the bandwidth to switch to pythonize because there is a large chunk of my company's code base using serde-pyobject by now.

@dylanbstorey
Copy link
Copy Markdown
Owner

alright - i’m going to merge with the git branch, its not my favorite thing but nbd

@dylanbstorey dylanbstorey marked this pull request as ready for review July 4, 2025 20:45
@dylanbstorey dylanbstorey merged commit 4d32eb8 into dylanbstorey:main Jul 4, 2025
@dylanbstorey
Copy link
Copy Markdown
Owner

well poop - TIL that crates won’t accept a git i’ll see about using pythonize

@dylanbstorey
Copy link
Copy Markdown
Owner

I switched over to pythonize so it at least should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants