Metadata-Version: 2.4
Name: llm-trace-sampler-py
Version: 0.1.0
Summary: Sample LLM traces by risk, errors, latency, and deterministic ids. Python port of @mukundakatta/llm-trace-sampler.
Project-URL: Homepage, https://github.com/MukundaKatta/llm-trace-sampler-py
Project-URL: Issues, https://github.com/MukundaKatta/llm-trace-sampler-py/issues
Project-URL: Source, https://github.com/MukundaKatta/llm-trace-sampler-py
Project-URL: JS sibling, https://www.npmjs.com/package/@mukundakatta/llm-trace-sampler
Author-email: Mukunda Katta <mukunda.vjcs6@gmail.com>
License: MIT
License-File: LICENSE
Keywords: agent,llm,observability,sampling,tracing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# llm-trace-sampler-py

Sample LLM traces by risk, errors, latency, and deterministic ids. Pure Python, zero deps. Python port of [`@mukundakatta/llm-trace-sampler`](https://www.npmjs.com/package/@mukundakatta/llm-trace-sampler).

```bash
pip install llm-trace-sampler-py
```

```python
from llm_trace_sampler import should_sample_trace, sample_traces

# Always sample errors / high-risk / slow traces; sample 10% of the rest.
should_sample_trace({"id": "abc", "error": "boom"})
# SampleDecision(sample=True, reason='priority')

sampled = sample_traces(my_traces, rate=0.1, risk_threshold=0.7, latency_ms=10_000)
```

Deterministic by trace id — the same id is always sampled / not sampled.

## License

MIT
