A standardized, file-based telemetry toolkit for LLM Agents.
Project description
๐ค LLM Telemetry Toolkit
A standardized, async-first observability system for LLM Agents. Zero-latency logging, beautiful metrics, and deep telemetry for production AI systems.
โจ Design Goals
-
Zero Latency Impact Logging happens in a background thread via
queue.Queue. Your Agent's "Process Loop" is never blocked by file I/O. -
"Masterpiece" Developer Experience From beautiful Rich-powered CLI dashboards to zero-friction
@monitor_interactiondecorators, every interaction feels expertly crafted. -
Smart Parsing Automatically detects reasoning traces (
<think>tags) and segregates them from the final response. Handles PII redaction intelligently. -
Implicit Context Uses
contextvarsto track sessions across deep function stacks without passingsession_idarguments everywhere.
โญ Features
- Multi-Format Logging: Generate
JSONdossiers, human-readableMarkdownreports, andCSVdatasets simultaneously. - Rich CLI Dashboard: Visualize your agent's performance with a beautiful terminal UI (
viewandstatscommands). - Smart PII Redaction: "Smart Masking" for Emails (
r***@example.com), IPs, Phones, and Credit Cards. (Opt-in) - Ollama Native Support: Captures deep metadata (load duration, eval count, quantization) from local Ollama providers.
- Robust Schema: Built on Pydantic v2 for strict validation and typing.
๐ Installation
pip install llm-telemetry-toolkit
# Ensure you have 'rich' for the CLI experience (installed by default)
๐งช Quick Start
The toolkit uses "Smart Defaults" so you can start logging with zero configuration.
from llm_telemetry_toolkit import LLMLogger, TelemetryConfig, monitor_interaction
# 1. Zero-Config initialization
# - session_id auto-generated (session_YYYYMMDD_HHMMSS)
# - logs written to ./logs
config = TelemetryConfig()
logger = LLMLogger(config)
# 2. Decorate your LLM function
@monitor_interaction(logger)
def chat_completion(prompt: str) -> str:
# Simulate LLM call
return "The sky is blue because of Rayleigh scattering."
# 3. Run!
print(chat_completion("Why is the sky blue?"))
# -> Logs are automatically written to ./logs/llm_interactions/session_.../
๐ ๏ธ Command-Line Interface (CLI)
The toolkit comes with a "sexy" CLI for viewing logs and calculating costs.
View Logs
Displays color-coded panels with syntax highlighting for prompts and responses.
python -m llm_telemetry_toolkit.interface.cli view --session ollama_test_004910
Calculate Stats
Aggregates token counts, latency, and estimated cost.
python -m llm_telemetry_toolkit.interface.cli stats --session ollama_test_004910
Example Output:
โโโโโโโโโโโโโโโโโโโโโ Session Statistics: ollama_test_004910 โโโโโโโโโโโโโโโโโโโโโ
โ Metric โ Value โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Total Interactions โ 7 โ
โ Total Latency โ 65.57s โ
โ Avg Latency โ 9.37s โ
โ Total Cost โ $0.00000 โ
โ Total Tokens โ 3268 โ
โ - Prompt โ 2454 โ
โ - Response โ 814 โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ Configuration
The TelemetryConfig object controls all behavior.
| Field | Type | Default | Description |
|---|---|---|---|
session_id |
str |
session_Timestamp |
Unique identifier for the logging session. |
base_log_dir |
Path |
./logs |
Root directory for storing logs. |
enable_session_logging |
bool |
True |
Group logs by session ID. |
enable_entity_logging |
bool |
False |
Fork logs into entity folders (e.g., 'Company A'). |
output_formats |
List[str] |
['json'] |
Supported: 'json', 'md', 'csv'. |
mask_pii |
bool |
False |
Enable regex-based PII redaction. (Opt-in) |
max_content_length |
int |
None |
Truncate prompts/responses longer than this chars. |
json_indent |
int |
2 |
Indentation for JSON files. |
๐ค Agents & MCP Server Integration
This toolkit is designed to be the "Telemetry Layer" for Agentic frameworks or MCP Servers.
1. Manual Logging (for Traceability)
If you can't use decorators, use the manual API.
from llm_telemetry_toolkit import LLMInteraction
# ... inside your MCP tool execution ...
interaction = LLMInteraction(
session_id="agent_run_x",
model_name="deepseek:r1",
prompt=tool_input,
response=tool_output,
response_time_seconds=latency,
# Capture Deep Metadata from Ollama/Providers
metadata={
"ollama_stats": {
"total_duration_ns": 1500000000,
"load_duration_ns": 500000000,
"prompt_eval_count": 45,
"eval_count": 120
},
"tool_name": "web_scraper",
"url": "example.com"
}
)
# Non-blocking write
logger.log(interaction)
2. Context Management
Use SessionContext to implicitly pass session IDs through your call stack.
from llm_telemetry_toolkit import SessionContext
def my_deeply_nested_function():
# Automatically picks up "user_session_abc" from context
logger.log(interaction)
with SessionContext("user_session_abc"):
my_deeply_nested_function()
๐ Smart Parsing & PII
reasoning-trace extraction ()
If your model (e.g., DeepSeek R1, Groq) returns <think> blocks, the toolkit automatically extracts them into a separate thought_process field in the JSON log, keeping the response clean.
Smart Masking (PII)
Enable via TelemetryConfig(mask_pii=True). This is Opt-in and disabled by default.
When enabled, sensitive data is redacted while preserving debug context:
- Email:
roy@example.com->r***@example.com - IP:
192.168.1.1->192.xxx.xxx.xxx - Credit Card:
4111 2222 3333 4444->4111 xxxx xxxx 4444 - Phone:
+1 (555) 123-4567->+1 (555) ***-**67
๐ฆ Example Log Output (Ollama)
{
"interaction_id": "ollama_test_004910_llm_0003",
"session_id": "ollama_test_004910",
"timestamp_utc": "2025-12-12T07:49:34.550928+00:00",
"model_name": "ministral-3:latest",
"provider": "ollama_local",
"prompt": "Explain why the sky is blue in one concise sentence.",
"response": "The sky appears blue because Earth's atmosphere scatters shorter (blue) wavelengths of sunlight more than other colors due to a phenomenon called **Rayleigh scattering**.",
"response_time_seconds": 7.78,
"token_count_prompt": 551,
"token_count_response": 33,
"metadata": {
"ollama_details": {
"format": "gguf",
"family": "mistral3",
"parameter_size": "8.9B",
"quantization_level": "Q4_K_M"
},
"ollama_stats": {
"total_duration_ns": 7757972341,
"load_duration_ns": 6139982699,
"eval_count": 33
}
}
}
๐ฆ License
MIT. Created by Roy Dawson IV.
Project details
Release history Release notifications | RSS feed
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 llm_telemetry_toolkit-0.1.0.tar.gz.
File metadata
- Download URL: llm_telemetry_toolkit-0.1.0.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ff0c00ff686e6b847125b4ff400db718a9bdd42a028f6132468df436cacc8c7
|
|
| MD5 |
19867f07636bacd351c5139bf502ee67
|
|
| BLAKE2b-256 |
de7c5e8d170241c3e6ae0b51d674ff90d2800efac73f55cc77a4d48da114a2c3
|
Provenance
The following attestation bundles were made for llm_telemetry_toolkit-0.1.0.tar.gz:
Publisher:
python-publish.yml on ImYourBoyRoy/llm-telemetry-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_telemetry_toolkit-0.1.0.tar.gz -
Subject digest:
3ff0c00ff686e6b847125b4ff400db718a9bdd42a028f6132468df436cacc8c7 - Sigstore transparency entry: 760868208
- Sigstore integration time:
-
Permalink:
ImYourBoyRoy/llm-telemetry-toolkit@ee8de44e481cac0e884c062faab7aea76cd9c639 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ImYourBoyRoy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ee8de44e481cac0e884c062faab7aea76cd9c639 -
Trigger Event:
release
-
Statement type:
File details
Details for the file llm_telemetry_toolkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llm_telemetry_toolkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e7ce9076eacc9eb17cfb9dff843f85ba7d239c1f3a58d5e6f4775ebe588068c
|
|
| MD5 |
9366b08762d6ae72119c2efa9bef7802
|
|
| BLAKE2b-256 |
df8da5561f86ca696ec619d968b49038de79349c1c425d0481e5b50a48695960
|
Provenance
The following attestation bundles were made for llm_telemetry_toolkit-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on ImYourBoyRoy/llm-telemetry-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_telemetry_toolkit-0.1.0-py3-none-any.whl -
Subject digest:
4e7ce9076eacc9eb17cfb9dff843f85ba7d239c1f3a58d5e6f4775ebe588068c - Sigstore transparency entry: 760868214
- Sigstore integration time:
-
Permalink:
ImYourBoyRoy/llm-telemetry-toolkit@ee8de44e481cac0e884c062faab7aea76cd9c639 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ImYourBoyRoy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ee8de44e481cac0e884c062faab7aea76cd9c639 -
Trigger Event:
release
-
Statement type: