Skip to content

Commit 0cfb9f4

Browse files
committed
WS6-2
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]>
1 parent f8d1508 commit 0cfb9f4

File tree

7 files changed

+627
-6
lines changed

7 files changed

+627
-6
lines changed

Justfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ bench:
5151
echo "Python interpreter not found. Run 'just venv <version>' first."; \
5252
exit 1; \
5353
fi; \
54-
PYO3_PYTHON="$PYTHON_BIN" uv run cargo bench --manifest-path codetracer-python-recorder/Cargo.toml --no-default-features --bench trace_filter
54+
PERF_DIR="$ROOT/codetracer-python-recorder/target/perf"; \
55+
mkdir -p "$PERF_DIR"; \
56+
PYO3_PYTHON="$PYTHON_BIN" uv run cargo bench --manifest-path codetracer-python-recorder/Cargo.toml --no-default-features --bench trace_filter && \
57+
CODETRACER_TRACE_FILTER_PERF=1 \
58+
CODETRACER_TRACE_FILTER_PERF_OUTPUT="$PERF_DIR/trace_filter_py.json" \
59+
uv run --group dev --group test pytest codetracer-python-recorder/tests/python/perf/test_trace_filter_perf.py -q
5560

5661
py-test:
5762
uv run --group dev --group test pytest codetracer-python-recorder/tests/python codetracer-pure-python-recorder

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Basic workflow:
137137
- Run the full split test suite (Rust nextest + Python pytest): `just test`
138138
- Run only Rust integration/unit tests: `just cargo-test`
139139
- Run only Python tests (including the pure-Python recorder to guard regressions): `just py-test`
140+
- Exercise the trace-filter benchmarks (Rust Criterion + Python smoke, JSON output under `codetracer-python-recorder/target/perf`): `just bench`
140141
- Collect coverage artefacts locally (LCOV + Cobertura/JSON): `just coverage`
141142

142143
The CI workflow mirrors these commands. Pull requests get an automated comment with the latest Rust/Python coverage tables and downloadable artefacts (`lcov.info`, `coverage.xml`, `coverage.json`).

codetracer-python-recorder/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,33 @@ All additional arguments are forwarded to the target script unchanged. The CLI
5151
reuses whichever interpreter launches it so wrappers such as `uv run`, `pipx`,
5252
or activated virtual environments behave identically to `python script.py`.
5353

54+
## Trace filter configuration
55+
- Filter files are TOML with `[meta]`, `[scope]`, and `[[scope.rules]]` tables. Rules evaluate in declaration order and can tweak both execution (`exec`) and value decisions (`value_default`).
56+
- Supported selector domains: `pkg`, `file`, `obj` for scopes; `local`, `global`, `arg`, `ret`, `attr` for value policies. Match types default to `glob` and also accept `regex` or `literal` (e.g. `local:regex:^(metric|masked)_\w+$`).
57+
- Default discovery: `.codetracer/trace-filter.toml` next to the traced script. Chain additional files via CLI (`--trace-filter path_a --trace-filter path_b`), environment variable (`CODETRACER_TRACE_FILTER=path_a//path_b`), or Python helpers (`trace(..., trace_filter=[path_a, path_b])`). Later entries override earlier ones when selectors overlap.
58+
- Runtime metadata captures the active chain under `trace_metadata.json -> trace_filter`, including per-kind redaction counters. See `docs/onboarding/trace-filters.md` for the full DSL reference and examples.
59+
60+
Example snippet:
61+
```toml
62+
[meta]
63+
name = "local-redaction"
64+
version = 1
65+
66+
[scope]
67+
default_exec = "trace"
68+
default_value_action = "allow"
69+
70+
[[scope.rules]]
71+
selector = "pkg:my_app.services.*"
72+
value_default = "deny"
73+
[[scope.rules.value_patterns]]
74+
selector = "local:glob:public_*"
75+
action = "allow"
76+
[[scope.rules.value_patterns]]
77+
selector = 'local:regex:^(metric|masked)_\w+$'
78+
action = "allow"
79+
```
80+
5481
## Packaging expectations
5582

5683
Desktop installers add the wheel to `PYTHONPATH` before invoking the user’s
@@ -61,3 +88,8 @@ with the interpreter you want to trace.
6188
The CLI writes recorder metadata into `trace_metadata.json` describing the wheel
6289
version, target script, and diff preference so downstream tooling can make
6390
decisions without re-running the trace.
91+
92+
## Development benchmarks
93+
- Rust microbench: `cargo bench --bench trace_filter --no-default-features` exercises baseline, glob-heavy, and regex-heavy selector chains.
94+
- Python smoke benchmark: `pytest codetracer-python-recorder/tests/python/perf/test_trace_filter_perf.py -q` when the environment variable `CODETRACER_TRACE_FILTER_PERF=1` is set.
95+
- Run both together with `just bench`. The helper seeds a virtualenv, runs Criterion, then executes the Python smoke test while writing `target/perf/trace_filter_py.json` (per-scenario durations and redaction statistics).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Performance-oriented smoke tests for the Python surface."""

0 commit comments

Comments
 (0)