lexigram-ai-observability
AI observability for the Lexigram Framework — tracing, metrics, and monitoring
Overview
AI-layer observability for the Lexigram Framework. Provides tracing, metrics, health monitoring, and decorator-based instrumentation for LLM calls, RAG operations, and vector store interactions — all wired through the DI container via ObservabilityModule. Zero-config usage starts with sensible defaults.
Full documentation: docs.lexigram.dev
Install
uv add lexigram-ai-observability
# Optional extras
uv add "lexigram-ai-observability[opentelemetry]"
Quick Start
from lexigram import Application
from lexigram.di.module import Module, module
from lexigram.ai.observability import ObservabilityModule
from lexigram.ai.observability.config import ObservabilityConfig
@module(imports=[
ObservabilityModule.configure(
ObservabilityConfig(
enabled=True,
metrics_enabled=True,
tracing_enabled=True,
health_checks_enabled=True,
)
)
])
class AppModule(Module):
pass
app = Application(modules=[AppModule])
if __name__ == "__main__":
app.run()
Configuration
Zero-config usage: Call
ObservabilityModule.configure()with no arguments to use defaults.
Option 1 — YAML file
# application.yaml
ai_observability:
enabled: true
metrics_enabled: true
tracing_enabled: true
health_checks_enabled: true
Option 2 — Profiles + Environment Variables (recommended)
export LEX_AI_OBSERVABILITY__ENABLED=true
# Environment variables for each field
Option 3 — Python
from lexigram.ai.observability.config import ObservabilityConfig
from lexigram.ai.observability import ObservabilityModule
config = ObservabilityConfig(
enabled=True,
metrics_enabled=True,
tracing_enabled=True,
health_checks_enabled=True,
)
ObservabilityModule.configure(config)
Config reference
| Field | Default | Env var | Description |
|---|---|---|---|
enabled |
True |
LEX_AI_OBSERVABILITY__ENABLED |
Master on/off switch for all observability |
metrics_enabled |
True |
LEX_AI_OBSERVABILITY__METRICS_ENABLED |
Enable metrics collection |
tracing_enabled |
True |
LEX_AI_OBSERVABILITY__TRACING_ENABLED |
Enable distributed tracing |
health_checks_enabled |
True |
LEX_AI_OBSERVABILITY__HEALTH_CHECKS_ENABLED |
Enable background health checking |
Module Factory Methods
| Method | Description |
|---|---|
ObservabilityModule.configure(config) |
Fully-configured observability module |
ObservabilityModule.stub() |
No-op observability for testing |
Key Features
- Tracing: Distributed tracing for LLM calls, RAG pipeline stages, and vector store queries
- Metrics: Token usage, latency, error rates, and cache hit ratios
- Health monitoring: Background health checks for AI components
- Decorators:
@trace_llm,@trace_rag,@track_llm_callfor automatic instrumentation - Observable wrappers:
ObservableLLMClientandObservableVectorStore - OpenTelemetry support: Optional OpenTelemetry integration
Testing
async with Application.boot(modules=[ObservabilityModule.stub()]) as app:
# your test code
...
Key Source Files
| File | What it contains |
|---|---|
src/lexigram/ai/observability/module.py |
Module factory — configure() and stub() |
src/lexigram/ai/observability/config.py |
ObservabilityConfig — environment-aware settings |
src/lexigram/ai/observability/di/provider.py |
ObservabilityProvider — registers observability services |
src/lexigram/ai/observability/tracing/ |
AITracer — distributed tracing for AI operations |
src/lexigram/ai/observability/metrics/ |
AIMetrics — token usage, latency, error rates |
src/lexigram/ai/observability/health/ |
AIHealthMonitor — background health checks |
src/lexigram/ai/observability/decorators.py |
@trace_llm, @trace_rag, @track_llm_call |
src/lexigram/ai/observability/exceptions.py |
Typed exceptions |
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 lexigram_ai_observability-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lexigram_ai_observability-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
656679eb3071c0b30068c2b7c10bd4ac452c4cb8f84fd4b8dc5b510062f057bc
|
|
| MD5 |
a69dfd0a97ffffe98c3e5dfb23a33784
|
|
| BLAKE2b-256 |
2ede42ee02d5b7e3e2f07c56fc08157e1f5a0c9c100e586fdb4c201ab053ca7c
|