Skip to main content

Low-level Rust-backed Python module for CodeTracer recording (PyO3)

Project description

Codetracer Python Recorder

codetracer-python-recorder is the Rust-backed recorder module that powers Python tracing inside Codetracer. The PyO3 extension exposes a small Python façade so packaged environments (desktop bundles, uv run, virtualenvs) can start and stop recording without shipping an additional interpreter.

Installation

codetracer-python-recorder publishes binary wheels for CPython 3.12 and 3.13 on Linux (manylinux2014 x86_64/aarch64), macOS 11+ universal2 (arm64 + x86_64), and Windows 10+ (win_amd64). Install the package into the interpreter you plan to trace:

python -m pip install codetracer-python-recorder

Source distributions are available for audit and custom builds; maturin and a Rust toolchain are required when building from source.

Command-line entry point

The wheel installs a console script named codetracer-python-recorder and the package can also be invoked with python -m codetracer_python_recorder. Both forms share the same arguments:

python -m codetracer_python_recorder \
  --trace-dir ./trace-out \
  --format json \
  --activation-path app/main.py \
  --trace-filter config/trace-filter.toml \
  app/main.py --arg=value
  • --trace-dir (default: ./trace-out) – directory that will receive trace.json, trace_metadata.json, and trace_paths.json.
  • --format – trace serialisation format (binary or json). Use json for integration with the DB backend importer.
  • --activation-path – optional gate that postpones tracing until the interpreter executes this file (defaults to the target script).
  • --trace-filter – path to a filter file. Provide multiple times or use :: separators within a single argument to build a chain. When present, the recorder prepends the project default .codetracer/trace-filter.toml (if found near the target script) so later entries override the defaults. The CODETRACER_TRACE_FILTER environment variable accepts the same ::-separated syntax when using the auto-start hook.

All additional arguments are forwarded to the target script unchanged. The CLI reuses whichever interpreter launches it so wrappers such as uv run, pipx, or activated virtual environments behave identically to python script.py.

Trace filter configuration

  • 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).
  • 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+$).
  • 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.
  • A built-in builtin-default filter is always prepended. It skips CPython standard-library frames (e.g. asyncio, threading, importlib) while re-enabling third-party packages under site-packages (except helpers such as _virtualenv.py), and redacts common secrets (password, token, API keys, etc.) across locals/globals/args/returns/attributes. Project filters can loosen or tighten these defaults as required.
  • Runtime metadata captures the active chain under trace_metadata.json -> trace_filter, including per-kind redaction and drop counters. See docs/onboarding/trace-filters.md for the full DSL reference and examples.

Example snippet:

[meta]
name = "local-redaction"
version = 1

[scope]
default_exec = "trace"
default_value_action = "allow"

[[scope.rules]]
selector = "pkg:my_app.services.*"
value_default = "redact"
[[scope.rules.value_patterns]]
selector = "local:glob:public_*"
action = "allow"
[[scope.rules.value_patterns]]
selector = 'local:regex:^(metric|masked)_\w+$'
action = "allow"
[[scope.rules.value_patterns]]
selector = "arg:literal:debug_payload"
action = "drop"

Packaging expectations

Desktop installers add the wheel to PYTHONPATH before invoking the user’s interpreter. When embedding the recorder elsewhere, ensure the wheel (or its extracted site-packages directory) is discoverable on sys.path and run the CLI with the interpreter you want to trace.

The CLI writes recorder metadata into trace_metadata.json describing the wheel version, target script, and diff preference so downstream tooling can make decisions without re-running the trace.

Development benchmarks

  • Rust microbench: cargo bench --bench trace_filter --no-default-features exercises baseline, glob-heavy, and regex-heavy selector chains.
  • 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.
  • 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 plus redaction/drop statistics).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codetracer_python_recorder-0.2.0.tar.gz (125.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

codetracer_python_recorder-0.2.0-cp313-cp313-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.13Windows x86-64

codetracer_python_recorder-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

codetracer_python_recorder-0.2.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

codetracer_python_recorder-0.2.0-cp313-cp313-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

codetracer_python_recorder-0.2.0-cp313-cp313-macosx_10_12_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

codetracer_python_recorder-0.2.0-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12Windows x86-64

codetracer_python_recorder-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

codetracer_python_recorder-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

codetracer_python_recorder-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

codetracer_python_recorder-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file codetracer_python_recorder-0.2.0.tar.gz.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0.tar.gz
Algorithm Hash digest
SHA256 59ed1a42951bd757e4fbbfa0772d6884d3a8d948cb43d8ed8c55f4debba0e56a
MD5 13c1b823fb0b05abdbd6097eaca35cf8
BLAKE2b-256 6d5be90e5a2348dbea29b31b03fe223a6a0c351911424fe63c2f7016782b00a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0.tar.gz:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d5c8951a975cfa2c074c74b5bb37184fbe3a6c880224e93e8db1015d9fb0b79e
MD5 de57ba9961b4ccf4e4d0b9e0bc1ccae0
BLAKE2b-256 b84e6ebb15bafa9bd5c729ce328e43440e19640e8fc35b196428c3cabea7fce7

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp313-cp313-win_amd64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1ea6a9262c3b5289832ae55356ccd6f2aede3d48f38a2f1ca701a57394ac1e66
MD5 8b2a454fbcc98507cf6b0e6ee2d433a8
BLAKE2b-256 e86c49524ccb80d8fdcd28e1f549859dfc4e30249debaa2b7dd114750465446d

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3afd633e961eabb8057d0ce9fd7fd4179743402298979ce549748c34185e7e3a
MD5 80e3e24efbef4c8af45f26b45b46c0fb
BLAKE2b-256 bc26d3603d92fe736082e7922a62d8690df805cf22cf8a2df201fe64ff063872

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d8ad916d2872deef502009c62623849785d04a8c3603271f4ceeb55613a7050f
MD5 76f848abd017936baba763fbe92b83a2
BLAKE2b-256 ff1aa527b0ee8a0d80a7985d8471dd680a3a6d509b956ecbc5bde4d7ee397f64

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a6c8489765b1b7385746f4ba08a76cb4ecac3f4162d22beb23290ac6ac20995e
MD5 d7b7d63b7263d731a444777ec7e56f31
BLAKE2b-256 fd7b25019cf299f32679ad4f31d5bfd89eedbf57031ed0e7c6dd4a8719cfd61c

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 70d7795bea0c675648a849fa1948a8612c88facde0d26043736eea2991d36c85
MD5 5a75ddb9a5cb13177349dd587f673aa7
BLAKE2b-256 d2663ed5e9e2e47035853168463e63389a6bf14075c24408ae5a5fb169946e14

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp312-cp312-win_amd64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26a446b117ea261bcf0b68e4bba6421f4a7d1f73a20d35953a594561a59b0631
MD5 5010e9debf1ce2f54ae3acd766e7d5e5
BLAKE2b-256 f9cb78832a1fbde967e26fe05802d7d77cb5ad6ecf9d97a7ed25431ae942de4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dfa497111c2f7f63301a43ba8b12ff3beec4a0b8a27a6d590fe74f62f1c85816
MD5 82709e7d03924c64a6d76b19283de075
BLAKE2b-256 52e8e8782e78a2e5efe26bc50ebf9cf296b9962d3c6927d97c3f2a857bada215

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 378eb0c701cdc93101b1a8018a89cb48d42be879941e6d11ffedf7bb837625b5
MD5 5c4ebf117b5c003cb97dcde2ff6eda36
BLAKE2b-256 87dd67b9191a8671e3fa69e8cefa49b6343b9169b78a6d5daeb4dd7f31607b85

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codetracer_python_recorder-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for codetracer_python_recorder-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 37d23a289f3df2091f650e4c18d7beaf70a9185f3f9c28dbbc0fc94612e5fbba
MD5 39b68209e9a8899f1932173ea7e8e644
BLAKE2b-256 be791d4176b794d16a87cb2fd2eaf831b6e5af7d78a5fc706dcb79b108c6d346

See more details on using hashes here.

Provenance

The following attestation bundles were made for codetracer_python_recorder-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: recorder-release.yml on metacraft-labs/codetracer-python-recorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page