What is Laminar?
Laminar is an observability platform specifically designed for LLM applications. It provides:- Trace visualization - See every LLM call with full prompts and responses
- Cost tracking - Monitor token usage and API costs
- Performance analysis - Identify slow calls and bottlenecks
- Accuracy verification - Detect hallucinations and errors
- Agent debugging - Track multi-step agent workflows
Get Started with Laminar
Sign up for free and get your API key at lmnr.ai
Setup
Installation
Laminar SDK is included in JARVIS dependencies:pyproject.toml
Configuration
Set your Laminar API key:.env
Initialization
Laminar is automatically initialized at application startup:backend/observability/laminar.py
Tracing Functions
Basic @observe Decorator
Use the@observe decorator from the Laminar SDK:
- Creates a trace span
- Records start/end timestamps
- Captures function arguments and return values
- Sends to Laminar dashboard
Enhanced @traced Decorator
JARVIS provides an enhanced decorator that combines logging and tracing:backend/observability/laminar.py
@traced decorator:
- Logs start/end with duration to console
- Sends spans to Laminar (if configured)
- Works with both sync and async functions
- Includes custom metadata and tags
- Gracefully degrades if Laminar is not configured
Implementation
backend/observability/laminar.py
Real-World Examples
Tracing Face Identification
backend/identification/pimeyes.py
Tracing Agent Swarm
backend/agents/orchestrator.py
Tracing Report Synthesis
backend/synthesis/synthesizer.py
Viewing Traces
Laminar Dashboard
Access your traces at app.lmnr.ai:- Traces View - See all traces with duration and status
- Trace Detail - Click a trace to see full span tree
- LLM Calls - View prompts, responses, and token usage
- Filters - Filter by metadata tags, status, duration
Trace Hierarchy
A typical JARVIS trace shows:LLM Call Details
Click on an LLM span to see:- Full prompt - Exact prompt sent to the model
- Response - Complete response from the model
- Tokens - Prompt tokens, completion tokens, total
- Cost - Estimated API cost
- Latency - Time to first token, total duration
- Model - Model name and version
Filtering and Analysis
Filter by Tags
Use tags to filter traces:- Filter by tag:
tags:critical-path - Show only agent calls:
tags:agent - Show errors:
status:error
Filter by Metadata
Add metadata for richer filtering:metadata.agent_type:linkedinmetadata.llm:gemini*
Performance Analysis
- Identify slow calls: Sort by duration
- Token usage: Sum tokens by model
- Error rate: Filter by
status:error - Cost tracking: View total API costs
Best Practices
Trace all LLM calls
Trace all LLM calls
Every function that calls an LLM should be traced:
Use descriptive names
Use descriptive names
Name traces clearly to identify them in the dashboard:
Add contextual metadata
Add contextual metadata
Include IDs and parameters for debugging:
Tag critical paths
Tag critical paths
Use tags to identify important traces:
Graceful degradation
Graceful degradation
Always design tracing to degrade gracefully:
Troubleshooting
Traces Not Appearing
Test with simple trace
High Overhead
If tracing adds too much latency:-
Sample traces: Only trace 10% of requests
-
Disable in production: Set
LMNR_PROJECT_API_KEY=to disable - Reduce span depth: Only trace top-level functions
Missing Context
If traces lack context:Next Steps
Observability
Learn about the full observability stack
Performance
Optimize performance based on traces
Deployment
Deploy with production tracing
Architecture
Understand system architecture