call-tracer
call-tracer is a library for tracing function calls with depth control and filtering.
Installation
pip install call-tracer
(Required: python >= 3.6)
Usage
Basic Usage
from calltracer import tracer
def add_one(n):
return n+1
def add_two(n):
n = add_one(n)
n = add_one(n)
return n
@tracer
def main():
n = add_two(4)
main()
Alternatively, you can use tracer.start() instead of the decorator.
tracer.start()
add_two()
tracer.end()
Customizations
If you want to use tracer to monitor the internal workings of langchain, you'll encounter a tremendous number of calls and returns, each accompanied by very long file paths. Therefore, you may need to customize the tracer slightly:
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from calltracer import tracer
tracer.set_max_depth(3)
tracer.set_path_cuts(['python3.9'])
tracer.set_path_filters(['python3.9/abc', 'pydantic'])
@tracer
def main():
prompt = ChatPromptTemplate.from_messages([
("system", f"You are a helpful assistant"),
MessagesPlaceholder(variable_name="chat_history"),
("user", "{input}")
])
main()
set_max_depth: Set the maximum depth for tracing. (printsdepth<=max_depth)set_path_cuts: Specify paths to be shortened in the trace output to simplify and clean up the displayed file paths in the trace logs.- For example, if you use
trace.set_path_cuts(['PythonProjects']), the path/Users/your_name/PythonProjects/your_project/sample.pywill be shortened toyour_project/sample.py.
- For example, if you use
set_path_filters: Specify paths to be excluded from tracing, preventing the trace function from logging calls and returns for files matching these paths.set_show_args: IfTrue, the tracer displays the input arguments of the calls.
Contributing
- Pull requests are welcome.
- For major changes, please open an issue first to discuss what you would like to change.
- Please make sure to update tests as appropriate.
License
Metadata
Release files for call-tracer 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| call-tracer-1.2.2.tar.gz | 4.1 kB | Without provenance | Details for call-tracer-1.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| call_tracer-1.2.2-py3-none-any.whl | Python 3 | none | any | Details for call_tracer-1.2.2-py3-none-any.whl |
Total release size: 8.3 kB
Release files / call-tracer-1.2.2.tar.gz
| Download URL | call-tracer-1.2.2.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d39e96e1375611f897b630709e8c2751bd0855e03409156d1f07c139f5df41d3
|
|
BLAKE2b-256 checksum How to use checksums |
5312badffeeea193baf93e09e3a929e64b741b89a5e626e2b66bcc61b397925d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / call_tracer-1.2.2-py3-none-any.whl
| Download URL | call_tracer-1.2.2-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dbda4ca1efc26c1493846b03102ec77b493efba4c11d916aa985d0b9d8969dd6
|
|
BLAKE2b-256 checksum How to use checksums |
0ba53cd31e0dbe033d42cb13329563c73e5e2ef2016476fadfa883befe221116
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for call-tracer 1.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.