Skip to content

Conversation

@tzanko-matev
Copy link
Contributor

We are working on deriving a way to compute Python module names from the information that we get during tracing. This is first PR in a series of several

codetracer-python-recorder/resources/trace_filters/builtin_default.toml: 
codetracer-python-recorder/src/trace_filter/engine.rs: 
design-docs/adr/0013-reliable-module-name-derivation.md: 
design-docs/reliable-module-name-derivation-implementation-plan.md: 
design-docs/reliable-module-name-derivation-implementation-plan.status.md: 
docs/onboarding/trace-filters.md: 

Signed-off-by: Tzanko Matev <[email protected]>
@github-actions
Copy link

Coverage Summary

Rust (lines)
80.5% covered (7,750 / 9,624 | 1,874 missed)

File Lines Miss Cover
codetracer-python-recorder/src/logging/logger.rs 273 64 76.6%
codetracer-python-recorder/src/monitoring/api.rs 162 149 8.0%
codetracer-python-recorder/src/monitoring/callbacks.rs 589 68 88.5%
codetracer-python-recorder/src/runtime/frame_inspector.rs 148 63 57.4%
codetracer-python-recorder/src/runtime/io_capture/fd_mirror/unix.rs 376 79 79.0%
codetracer-python-recorder/src/runtime/io_capture/proxies/common.rs 159 62 61.0%
codetracer-python-recorder/src/runtime/io_capture/proxies/input.rs 128 91 28.9%
codetracer-python-recorder/src/runtime/io_capture/proxies/output.rs 41 27 34.1%
codetracer-python-recorder/src/runtime/io_capture/sink/batcher.rs 238 21 91.2%
codetracer-python-recorder/src/runtime/tracer/events.rs 439 250 43.1%
codetracer-python-recorder/src/runtime/tracer/filtering.rs 128 32 75.0%
codetracer-python-recorder/src/runtime/tracer/io.rs 162 31 80.9%
codetracer-python-recorder/src/runtime/tracer/lifecycle.rs 231 46 80.1%
codetracer-python-recorder/src/runtime/tracer/runtime_tracer.rs 1,702 57 96.7%
codetracer-python-recorder/src/runtime/value_capture.rs 260 130 50.0%
codetracer-python-recorder/src/session.rs 84 84 0.0%
codetracer-python-recorder/src/session/bootstrap/filesystem.rs 90 32 64.4%
codetracer-python-recorder/src/trace_filter/engine.rs 829 96 88.4%
codetracer-python-recorder/src/trace_filter/loader.rs 445 202 54.6%
codetracer-python-recorder/src/trace_filter/selector.rs 258 66 74.4%
Showing top 20 entries by missed lines (of 52 total).

Python (statements)
76.3% covered (232 / 304 | 72 missed)

File Stmts Miss Cover
codetracer-python-recorder/codetracer_python_recorder/__init__.py 7 0 100.0%
codetracer-python-recorder/codetracer_python_recorder/__main__.py 2 2 0.0%
codetracer-python-recorder/codetracer_python_recorder/api.py 5 0 100.0%
codetracer-python-recorder/codetracer_python_recorder/auto_start.py 24 2 91.7%
codetracer-python-recorder/codetracer_python_recorder/cli.py 142 62 56.3%
codetracer-python-recorder/codetracer_python_recorder/formats.py 13 1 92.3%
codetracer-python-recorder/codetracer_python_recorder/session.py 111 5 95.5%

Generated automatically via generate_coverage_comment.py.

@tzanko-matev
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +329 to +336
fn resolve_module_name(&self, py: Python<'_>, absolute: &str) -> Option<String> {
if let Some(entry) = self.module_cache.get(absolute) {
return entry.value().clone();
}
let resolved = module_name_from_roots(&self.module_roots, absolute)
.or_else(|| lookup_module_name(py, absolute));
self.module_cache
.insert(absolute.to_string(), resolved.clone());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate root-derived module names before caching

The new resolve_module_name short-circuits to module_name_from_roots and caches the result without checking whether that dotted name is actually a syntactically valid module. When sys.path contains overlapping prefixes (e.g. /usr/lib/python3.11 before /usr/lib/python3.11/lib-dynload), the helper returns strings like lib-dynload._asyncio.cpython-311-x86_64-linux-gnu.so, which fail package selectors such as pkg:literal:_asyncio. Because the invalid name is cached, the lookup_module_name fallback is never invoked and those frames remain unmatchable. The resolver should validate the candidate with is_valid_module_name (or similar) and fall back to the sys.modules scan on failure before inserting it into the cache.

Useful? React with 👍 / 👎.

Base automatically changed from fix-trace-filter-policy to main October 28, 2025 09:45
@tzanko-matev tzanko-matev merged commit fea593a into main Oct 28, 2025
3 checks passed
@tzanko-matev tzanko-matev deleted the reliable-module-name-derivation branch October 28, 2025 09:46
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