Skip to main content
Understanding these core concepts will help you get the most out of Lumina.

Traces and Spans

Lumina uses OpenTelemetry’s trace model.

Trace

A trace represents a complete request or operation in your application. Properties:
  • Unique trace_id
  • One or more spans
  • Start and end timestamps
  • Service name
Example:

Span

A span represents a single operation within a trace. Properties:
  • Unique span_id
  • Parent span_id (for child spans)
  • Operation name
  • Start and end timestamps
  • Attributes (key-value metadata)
Example:

Single-Span vs Multi-Span

Single-Span Trace: One operation per trace (simple LLM calls).
Multi-Span Trace: Multiple nested operations (complex workflows).

Attributes

Attributes are key-value pairs attached to spans.

Standard Attributes

Automatically extracted by Lumina:

Custom Attributes

Add your own metadata:
Use cases:
  • User identification
  • Session tracking
  • Feature flags
  • A/B test variants
  • Custom dimensions for analytics

Cost Calculation

Lumina automatically calculates costs based on provider pricing.

Supported Providers

How It Works

1. Extract model name
2. Get token counts
3. Calculate cost

Custom Pricing

For unlisted models, specify costs manually:

Quality Monitoring

Lumina tracks response quality with hybrid detection.

Exact Match (Fast)

Hash-based comparison for identical responses. Use case: Detect unexpected changes
Speed: Instant (hash comparison)

Semantic Similarity (Accurate)

AI-powered semantic comparison for meaning preservation. Use case: Detect quality degradation
Speed: ~100ms (Claude API call)

When to Use Each

Exact match:
  • Regression detection
  • Template responses
  • Structured output (JSON)
Semantic:
  • Natural language responses
  • Prompt engineering
  • A/B testing

Alerting

Lumina detects anomalies and sends alerts.

Cost Alerts

Triggered when costs spike above baseline. Example:

Quality Alerts

Triggered when response quality drops. Example:

Configuration

Set thresholds per service:

Replay Testing

Test changes against real production data.

Workflow

1. Capture baseline
2. Make changes Update your prompt in code. 3. Replay
4. Compare View side-by-side diff with semantic scoring.

Use Cases

Prompt engineering:
  • Test prompt variations
  • Optimize system messages
  • Validate few-shot examples
Model changes:
  • Compare model outputs
  • Validate cost/quality tradeoffs
  • Test provider switching
Infrastructure:
  • Test rate limiting
  • Validate caching
  • Load testing

Sampling

For high-volume workloads, sample a subset of traces.

Head-Based Sampling

Decide at trace start whether to record. Example:
Pros:
  • Low overhead
  • Predictable costs
Cons:
  • May miss rare errors
  • No dynamic adjustment

Conditional Sampling

Always sample important traces. Example:
Best of both worlds:
  • Sample routine operations at 10%
  • Capture all important events at 100%

Data Retention

Lumina automatically manages trace lifecycle.

Self-Hosted Defaults

  • Daily limit: 50,000 traces
  • Retention: 7 days
  • Cleanup: Automatic at midnight UTC

Custom Configuration

Archival

Export traces before deletion:

Architecture Components

Understanding the system architecture helps with deployment and troubleshooting.

Ingestion Service

Purpose: Receive and validate traces Responsibilities:
  • Accept OTLP/HTTP traces
  • Validate schema
  • Publish to NATS queue
Port: 9411

Worker Pool

Purpose: Process traces asynchronously Responsibilities:
  • Calculate costs
  • Extract metadata
  • Store in PostgreSQL
Scaling: Horizontal (add more workers)

Query API

Purpose: Retrieve traces and analytics Responsibilities:
  • Serve dashboard queries
  • Provide REST API
  • Cache frequent queries
Port: 8081

Replay Engine

Purpose: Re-execute traces with new parameters Responsibilities:
  • Capture replay sets
  • Execute with LLM APIs
  • Compare results
Port: 8082

Dashboard

Purpose: Visualization and management Responsibilities:
  • Display traces
  • Show analytics
  • Manage alerts
Port: 3000

Best Practices

Attribute Naming

Use consistent naming conventions: Good:
Bad:

Span Naming

Use descriptive, hierarchical names: Good:
Bad:

Error Handling

Always capture errors:

Cost Management

Monitor costs proactively:
  1. Set up cost alerts
  2. Review expensive queries daily
  3. Optimize high-cost endpoints
  4. Consider model downgrading for simple tasks

Next Steps

Quickstart

Install Lumina and send your first trace

SDK Reference

Complete SDK documentation

Multi-Span Tracing

Learn hierarchical tracing

Production Deployment

Deploy to production