Skip to main content

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_call for automatic instrumentation
  • Observable wrappers: ObservableLLMClient and ObservableVectorStore
  • 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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

lexigram_ai_observability-0.1.3006-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file lexigram_ai_observability-0.1.3006-py3-none-any.whl.

File metadata

File hashes

Hashes for lexigram_ai_observability-0.1.3006-py3-none-any.whl
Algorithm Hash digest
SHA256 a846dbf920ab5fa7d0032b9cc4a9137efc73fdc6e83f37a83338629917dddacf
MD5 a7edd7889b3039154ce782dcd15646ed
BLAKE2b-256 4afaa1bb5d506cc1da42d8ed6965097b9f9ba9476653a5fc67f4720894145651

See more details on using hashes here.

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