Execution tracing & performance observability for Python services
Project description
Tracepulse
Lightweight execution tracing and performance observability for synchronous and asynchronous Python code.
Table of Contents
- Features
- Quickstart
- Usage
- Sync example
- Async example
- Configuration & Context
- Advanced
- Suggested features
- License
- Release / PyPI
Tracepulse provides a simple decorator-based tracer that records function start/end, duration (ms precision), exceptions, and structured logs compatible with Loguru. It's intentionally minimal and safe for production use.
Highlights
- Zero configuration decorator:
@trace - Works with sync and async callables
- Structured, minimal overhead logs
- Integrates with
logurufor flexible output
Features
- Sync and Async tracing
- Structured execution logs (function name, args summary, duration)
- Failure telemetry capture (exception type, message, traceback)
- Duration measurement (millisecond precision)
- Loguru-backed logging integration (fallbacks to stdlib logging if
loguruis unavailable) - Minimal surface area and runtime overhead
Quickstart
Install from PyPI:
pip install tracepulse
Then add the tracer to a function:
from tracepulse import trace
@trace
def compute():
return sum(range(1_000_000))
compute()
Usage
Sync example
from tracepulse import trace
@trace
def heavy_work(x):
# your work here
return x * 2
heavy_work(10)
Async example
import asyncio
from tracepulse import trace
@trace
async def fetch():
await asyncio.sleep(1)
asyncio.run(fetch())
Notes:
@tracecan be applied to any callable; it preserves function signature and return value.- For heavy throughput code, prefer adding
@traceat higher-level boundaries (handlers, tasks) rather than inner hot loops.
Configuration & Context
set_level(level_str)— programmatically adjust console logging level (e.g.,set_level("DEBUG")).set_context(dict)— attach context tags to subsequent traces (returns a token). Example:
from tracepulse import set_context, clear_context
token = set_context({"request_id": "abcd-1234"})
# traces will include `request_id`
clear_context(token) # reset
These helpers let you add lightweight, application-level context to trace events without a heavy propagation system.
Advanced
- Logging: Tracepulse uses
loguruinternally by default; ifloguruis not installed the package falls back to the stdlibloggingmodule so basic demos and imports still work. - Data captured: function name, arg summary (optional), start timestamp, end timestamp, duration_ms, exception info (if any), and optional context tags.
Suggested / Future Features
- Pluggable backends (send traces to file/HTTP/OTel)
- Context propagation across threads/processes
- Sampled tracing to reduce overhead for very high throughput
- Richer argument serialization and PII scrubbing hooks
- CLI tooling to visualize recent traces locally
License
Important: do not claim the MIT license unless you include a LICENSE file in this repository and you intend to license the project under MIT. I did not add or change a LICENSE file here.
If you want to publish under MIT, add a LICENSE file containing the MIT text and then update metadata accordingly. If you need, I can add the MIT file for you.
Release / PyPI
If you plan to publish a new release to PyPI, bump the version in pyproject.toml, build, and upload.
Typical steps:
# bump version in pyproject.toml (we updated to 0.1.1)
python -m build
python -m twine upload dist/*
You will need a PyPI account and twine configured with credentials.
Changelog
- v0.1.1 — Documentation improvements, README refresh, version bump
- v0.1.2 — Added context helpers, runtime
set_level, and demo CLI
If you'd like, I can:
- Add the
LICENSEfile (MIT) and update metadata - Commit and tag the release and run the build/upload steps (I can show commands)
- Implement any suggested feature as a PR
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tracepulse-0.1.2.tar.gz.
File metadata
- Download URL: tracepulse-0.1.2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88038a56ba51728db9b71294260643744c54da0569c45b886781de5617a309ca
|
|
| MD5 |
c11cc77e921dfc47da1f86000bcf4b97
|
|
| BLAKE2b-256 |
2d0c82a427f34a692153af5171c142cf8a40bd87ebe955ba6cb6172869ba0f9f
|
File details
Details for the file tracepulse-0.1.2-py3-none-any.whl.
File metadata
- Download URL: tracepulse-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
467e94c459462f78b950842dc7bb91e42030ea8e7f3764bc25ac5734ec9093f2
|
|
| MD5 |
ad85914287b94c2090c74dcf1cf1b7a5
|
|
| BLAKE2b-256 |
72019482d6631351c6d4b6182c58857a3557a069f0360ddcf38b30f218ffc51b
|