gh-145238: Add native thread ID to logging record attributes#145655
gh-145238: Add native thread ID to logging record attributes#145655mvanhorn wants to merge 1 commit intopython:mainfrom
Conversation
Add a `nativeThreadId` attribute to `LogRecord` that exposes the OS-native thread ID via `threading.get_native_id()`. This is useful for correlating log entries with system tools like htop, strace, and perf that display native thread IDs. The attribute can be used in format strings as `%(nativeThreadId)d`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Just curious, @mvanhorn, why did you need to use Claude Code for this tiny change? |
|
@vsajip Fair question! I use Claude Code as my daily coding environment - it's how I navigate codebases, run tests, and write code. So even for smaller changes like this, it's just part of my normal workflow rather than something I specifically "needed" AI for. The implementation decisions (checking |
|
🤖 New build scheduled with the buildbot fleet by @vsajip for commit 5361ced 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F145655%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
Fixes #145238.
Adds a
nativeThreadIdattribute toLogRecordthat exposes the OS-native thread ID viathreading.get_native_id(). This is useful for correlating log entries with system tools likehtop,strace, andperfthat display native thread IDs.The attribute can be used in format strings as
%(nativeThreadId)d.On platforms where
get_native_idis not available, the attribute is set toNone.This contribution was developed with AI assistance (Claude Code).
📚 Documentation preview 📚: https://cpython-previews--145655.org.readthedocs.build/