-
-
Notifications
You must be signed in to change notification settings - Fork 1
Trace filters #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trace filters #53
Conversation
…sign Signed-off-by: Tzanko Matev <[email protected]>
configurable-trace-filters-implementation-plan.md: Initial design Signed-off-by: Tzanko Matev <[email protected]>
design-docs/configurable-trace-filters-implementation-plan.status.md: Signed-off-by: Tzanko Matev <[email protected]>
codetracer-python-recorder/Cargo.lock: codetracer-python-recorder/Cargo.toml: codetracer-python-recorder/src/trace_filter/config.rs: codetracer-python-recorder/src/trace_filter/mod.rs: design-docs/configurable-trace-filters-implementation-plan.status.md: Signed-off-by: Tzanko Matev <[email protected]>
codetracer-python-recorder/codetracer_python_recorder/auto_start.py: codetracer-python-recorder/codetracer_python_recorder/cli.py: codetracer-python-recorder/codetracer_python_recorder/session.py: codetracer-python-recorder/src/session/bootstrap.rs: codetracer-python-recorder/src/session.rs: codetracer-python-recorder/tests/python/test_cli_integration.py: codetracer-python-recorder/tests/python/unit/test_backend_exceptions.py: codetracer-python-recorder/tests/python/unit/test_cli.py: codetracer-python-recorder/tests/python/unit/test_session_helpers.py: design-docs/configurable-trace-filters-implementation-plan.status.md: Signed-off-by: Tzanko Matev <[email protected]>
codetracer-python-recorder/README.md: codetracer-python-recorder/codetracer_python_recorder/cli.py: codetracer-python-recorder/tests/python/unit/test_auto_start.py: design-docs/configurable-trace-filters-implementation-plan.status.md: design-docs/py-api-001.md: Signed-off-by: Tzanko Matev <[email protected]>
Justfile: codetracer-python-recorder/Cargo.lock: codetracer-python-recorder/Cargo.toml: codetracer-python-recorder/benches/trace_filter.rs: codetracer-python-recorder/src/lib.rs: codetracer-python-recorder/src/runtime/mod.rs: codetracer-python-recorder/src/runtime/value_capture.rs: codetracer-python-recorder/src/trace_filter/config.rs: codetracer-python-recorder/src/trace_filter/engine.rs: codetracer-python-recorder/src/trace_filter/mod.rs: codetracer-python-recorder/src/trace_filter/selector.rs: design-docs/configurable-trace-filters-implementation-plan.status.md: Signed-off-by: Tzanko Matev <[email protected]>
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
Justfile: README.md: codetracer-python-recorder/README.md: codetracer-python-recorder/tests/python/perf/__init__.py: codetracer-python-recorder/tests/python/perf/test_trace_filter_perf.py: design-docs/configurable-trace-filters-implementation-plan.status.md: docs/onboarding/trace-filters.md: Signed-off-by: Tzanko Matev <[email protected]>
codetracer-python-recorder/README.md: codetracer-python-recorder/codetracer_python_recorder/cli.py: codetracer-python-recorder/codetracer_python_recorder/session.py: codetracer-python-recorder/tests/python/unit/test_auto_start.py: codetracer-python-recorder/tests/python/unit/test_cli.py: codetracer-python-recorder/tests/python/unit/test_session_helpers.py: design-docs/US0028 - Configurable Python trace filters.md: design-docs/adr/0009-configurable-trace-filters.md: design-docs/adr/0010-codetracer-python-recorder-benchmarking.md: design-docs/codetracer-python-benchmarking-implementation-plan.md: design-docs/configurable-trace-filters-implementation-plan.md: design-docs/configurable-trace-filters-implementation-plan.status.md: design-docs/py-api-001.md: docs/onboarding/trace-filters.md: nix/flake.nix: Signed-off-by: Tzanko Matev <[email protected]>
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
1 similar comment
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
|
@codex review this |
There was a problem hiding this 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
7e3271e to
6193762
Compare
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
|
@codex review this. Did we fix your last comment? |
There was a problem hiding this 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".
340a8ae to
620fbd4
Compare
|
@codex review |
There was a problem hiding this 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".
| enverr!(ErrorCode::Io, "failed to collect program metadata") | ||
| .with_context("details", err.to_string()) | ||
| })?; | ||
| let trace_filter = load_trace_filter(explicit_trace_filters, &metadata.program)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default filter discovery ignores API target script
TraceSessionBootstrap::prepare determines the default .codetracer/trace-filter.toml by calling collect_program_metadata(py) and passing metadata.program into load_trace_filter. Because collect_program_metadata reads sys.argv[0], the lookup walks the host process’s path, not the script supplied by session.start()/trace(). When the API is used from a wrapper process to trace a different script, the project filter sitting next to the traced script is never discovered, contradicting the docs that say discovery happens near the target script. The search should fall back to the provided activation_path or the user‑supplied script path when present rather than sys.argv.
Useful? React with 👍 / 👎.
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
codetracer-python-recorder/README.md: codetracer-python-recorder/codetracer_python_recorder/cli.py: codetracer-python-recorder/resources/trace_filters/builtin_default.toml: codetracer-python-recorder/src/session/bootstrap.rs: codetracer-python-recorder/src/trace_filter/config.rs: codetracer-python-recorder/tests/python/test_cli_integration.py: design-docs/US0028 - Configurable Python trace filters.md: design-docs/adr/0009-configurable-trace-filters.md: design-docs/configurable-trace-filters-implementation-plan.md: design-docs/configurable-trace-filters-implementation-plan.status.md: design-docs/py-api-001.md: docs/onboarding/trace-filters.md: tf.toml: trace-out/trace_metadata.json: trace-out/trace_paths.json: Signed-off-by: Tzanko Matev <[email protected]>
8cb53c6 to
5c4fef6
Compare
|
I found several issues, but I'll merge the fixes later. First I want to merge a big refactor and then I'll add the trace-filter issues on top of them |
Coverage SummaryRust (lines)
Python (statements)
Generated automatically via |
Configurable Trace Filters
Overview
design-docs/US0028 - Configurable Python trace filters.md).trace_metadata.json.asyncio/concurrency internals) while still allowing third-party packages undersite-packages(except helper shims like_virtualenv.py) and (b) redacts common sensitive identifiers (passwords, tokens, API keys, etc.) across locals/globals/args/returns/attributes. Project filters and explicit overrides append after this baseline and can relax rules where needed.Filter Files
.codetracer/trace-filter.toml). Any other file can be supplied via CLI, environment variable, or Python API.[meta]–name,version(integer), optionaldescription.[scope]–default_exec("trace"/"skip"),default_value_action("allow"/"redact"/"drop").[[scope.rules]]in declaration order. Each rule has:selector– matches a package, file, or object (see selector syntax).execoverride ("trace"/"skip").value_defaultoverride ("allow"/"redact"/"drop").reasonstring stored in telemetry.[[scope.rules.value_patterns]]entries that refine value capture by selector.Selector Syntax
selectorprefix before the first colon):pkg– fully-qualified module name (package.module).file– source path relative to the project root (POSIX separators).obj– module-qualified object (package.module.func).local,global,arg,ret,attr– value-level selectors.kind:match:pattern):glob(default) – wildcard matching with/treated as a separator.regex– Rust/RE2-style regular expressions; invalid patterns log a single warning and fall back to configuration errors.literal– exact string match.local:token_*uses glob). Declare the match type explicitly when combining separators or anchors.Loading and Chaining Filters
RuntimeTracersearches for.codetracer/trace-filter.tomlnear the target script.--trace-filter path/to/filter.toml. Provide multiple times or use::within one argument to append more files.CODETRACER_TRACE_FILTER=filters/prod.toml::filters/hotfix.toml. Respected by the auto-start hook and the CLI.trace(..., trace_filter=[path1, path2])or pass a::-delimited string. Paths are expanded to absolute locations and must exist.builtin-defaultfilter first, then project defaults, CLI/env entries, and explicit Python API arguments. Later rules override earlier ones when selectors overlap.Runtime Metadata
trace_metadata.jsonnow exposes atrace_filterobject containing:filters– ordered list of filter summaries (name,version, SHA-256 digest, absolute path).stats.scopes_skipped– total number of code objects blocked byexec = "skip".stats.value_redactions– per-kind counts for redacted values (argument,local,global,return,attribute).stats.value_drops– per-kind counts for values removed entirely from the trace.Benchmarks and Guard Rails
cargo bench --bench trace_filter --no-default-featuresexercises baseline vs glob/regex-heavy rule sets.pytest codetracer-python-recorder/tests/python/perf/test_trace_filter_perf.pyruns end-to-end tracing with synthetic workloads whenCODETRACER_TRACE_FILTER_PERF=1.just benchorchestrates both:just venv).PYO3_PYTHONpinned to the virtualenv interpreter.codetracer-python-recorder/target/perf/trace_filter_py.json(durations plus redaction/drop stats per scenario).