Skip to main content

Zero-config decorator for tracing LLM calls

Project description

llmtrace-lite

Zero-config decorator for tracing LLM calls. Print-debugging for language model functions, nothing more.

What this is

A tiny Python decorator that logs basic metadata about LLM function calls: timing, model name, prompt/output sizes, and success/failure status. No dependencies, no configuration files, no dashboards. Just readable logs.

Installation

pip install llmtrace-lite

Usage

from llmtrace_lite import trace

@trace
def call_llm(prompt, model="gpt-4o"):
    # Your LLM call here
    response = some_llm_client.complete(prompt, model=model)
    return response

# Use it normally
result = call_llm("Explain quantum computing", model="gpt-4o")

Output:

[llmtrace] call_llm
  model: gpt-4o
  latency_ms: 842
  prompt_chars: 312
  output_chars: 1187
  status: success

File logging

Set LLMTRACE_FILE to append JSON lines instead:

export LLMTRACE_FILE=traces.jsonl
python your_script.py

Each line is a JSON object with trace metadata.

What this captures

  • Function name
  • Start/end timestamps
  • Latency (milliseconds)
  • Status (success or error)
  • Exception details (if error)
  • Model name (if passed as model kwarg)
  • Prompt size (characters, if arg named prompt)
  • Output size (characters, if return is string)
  • Retry count (if function has retries attribute)

What this is NOT

This is not:

  • An observability platform
  • A provider-specific SDK integration
  • An async framework
  • A monitoring dashboard
  • A production tracing system
  • Extensible middleware

If you need those things, use LangSmith, Phoenix, or OpenTelemetry.

This is for local debugging and quick sanity checks. That's it.

Requirements

  • Python 3.9+
  • Standard library only
  • No external dependencies

License

MIT

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

llmtrace_lite-0.0.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

llmtrace_lite-0.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file llmtrace_lite-0.0.1.tar.gz.

File metadata

  • Download URL: llmtrace_lite-0.0.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llmtrace_lite-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cfd674e924b1ddd3533ad3ef71aa7a770e27dfffbb1f6e8e538dbd08a05de149
MD5 f09a2ba061c81cd27378f3d522acadc1
BLAKE2b-256 122154a32a3c9cda5f4c30a38d5066f09231d170b0ab5e8e5ff6cc7336e20cad

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmtrace_lite-0.0.1.tar.gz:

Publisher: publish.yml on achintya-p/llm-trace

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

File details

Details for the file llmtrace_lite-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: llmtrace_lite-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llmtrace_lite-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 650fd77e3d860a2df52930df48724f9181473cb8b8cdcc9712e004df88b00fd5
MD5 c498ba41ab0ea6e0f076e817b32c0167
BLAKE2b-256 bfea4e48fb7e215dbd56aacd02afc10edfa93a573e6f1bb5ab08d05bf0b229ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmtrace_lite-0.0.1-py3-none-any.whl:

Publisher: publish.yml on achintya-p/llm-trace

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