Observability Core Concepts
Basalt’s observability system is built on OpenTelemetry, providing deep insights into your LLM application’s behavior through distributed tracing, automatic instrumentation, and intelligent evaluation attachment.What is Observability?
Observability in Basalt allows you to:- Trace execution flows from prompt retrieval through LLM calls to final outputs
- Monitor performance with automatic timing and token usage tracking
- Evaluate quality by attaching evaluators to specific operations
- Track identity by associating user and organization context with operations
- Debug issues with detailed span hierarchies and error tracking
OpenTelemetry Architecture
Traces and Spans
Basalt uses OpenTelemetry’s trace and span model to represent your application’s execution:- Trace: A complete journey through your system, identified by a unique trace ID. All related operations share this ID.
- Span: A single operation within a trace, representing a unit of work (function call, API request, database query).
- Root Span: The entry point of a trace, created with
start_observe. Every trace must have exactly one root span. - Child Spans: Nested operations within a parent span, created with
observe.
Span Hierarchy
Spans form a parent-child tree structure:Context Propagation
One of Basalt’s most powerful features is automatic context propagation. When you set identity, evaluators, or metadata on a parent span, they automatically flow to all child spans.How Context Propagation Works
Basalt uses OpenTelemetry’s context mechanism to propagate data:- Context Storage: Data is stored in thread-local (or async-local) context
- Automatic Inheritance: Child spans read from parent context
- Span Processors: The
BasaltContextProcessorapplies context to spans on creation
What Gets Propagated
Identity (User & Organization):Span Kinds
Basalt defines semantic span kinds to categorize operations:| Kind | Use Case | Example |
|---|---|---|
GENERATION | LLM text generation | OpenAI completion, Claude response |
RETRIEVAL | Vector search, database queries | ChromaDB search, Pinecone query |
TOOL | Tool/function execution | Calculator, API call, web search |
FUNCTION | General function calls | Business logic, data processing |
EVENT | Discrete events | User action, notification sent |
SPAN | Generic operations | Default catch-all |
- Semantic filtering in dashboards
- Kind-specific evaluators
- Performance analysis by operation type
Evaluator Attachment
Evaluators are quality checks that run on span data after execution. Understanding how evaluators attach to spans is crucial for effective observability.Attachment Flow
Two Attachment Modes
Propagating (affects children):@evaluator(slugs=[...])decoratorwith_evaluators(...)context managerattach_evaluator(...)context manager- Global:
configure_trace_defaults(evaluators=[...])
span.add_evaluator(slug)methodattach_evaluators_to_span(...)helper
Sampling
Control evaluation costs with sampling:Prompt Integration
When you fetch a prompt using the context manager pattern, Basalt automatically creates a prompt span and injects attributes into subsequent LLM calls.Automatic Attribute Injection
The Complete Flow
- Tracking which prompt version was used for each generation
- A/B testing prompt variations
- Debugging prompt-related issues
- Analyzing performance by prompt
Identity Tracking
Identity tracking associates user and organization context with traces, enabling per-user analytics and debugging.Structure
Setting Identity
At root span:Benefits
- Filter traces by user or organization
- Debug user-specific issues
- Track usage per customer
- Implement user-based rate limiting
- Generate per-user analytics
Experiments
Experiments enable A/B testing, model comparison, and variant tracking.- Compare metrics between variants
- Track experiment performance over time
- Evaluate variant quality differences
Auto-Instrumentation
Basalt automatically instruments popular LLM providers, vector databases, and frameworks without code changes.How It Works
- Inherit evaluators from parent context
- Inherit identity (user/org) from parent context
- Automatically capture provider-specific attributes (model, tokens, etc.)
- Work seamlessly with manual
@observedecorators
Summary
Basalt’s observability system provides:- OpenTelemetry-based tracing - Industry-standard distributed tracing
- Automatic context propagation - Identity, evaluators, and metadata flow to children
- Flexible attachment modes - Propagating and non-propagating evaluators
- Prompt integration - Automatic attribute injection for LLM calls
- Semantic span kinds - Categorize operations for better analysis
- Auto-instrumentation - Zero-code tracing for popular providers
- Identity tracking - Per-user and per-org analytics
- Experiments - Built-in A/B testing support
- Patterns Guide - Decorators vs context managers
- Workflows Guide - End-to-end examples
- Evaluators Guide - Quality evaluation
- API Reference - Complete method documentation