Documentation Index
Fetch the complete documentation index at: https://docs.honeyhive.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Custom spans let you trace specific business logic, workflow steps, and application components beyond just LLM calls. Use Cases:- Business process tracking
- Performance bottleneck identification
- Complex workflow visualization
- Custom error tracking
The @trace Decorator
The recommended approach for function-level tracing:
- ✅ Automatic inputs/outputs capture
- ✅ Nested calls create proper trace hierarchy
- ✅ Clean code without span management clutter
For details on adding metadata with
enrich_span(), see Enriching Traces.Async Functions
The@trace decorator works with both sync and async functions automatically:
No separate
@atrace needed. The decorator detects async functions automatically.Context Managers
Use context managers for scenarios where decorators don’t fit:When to Use
- ✅ Loop iterations - Tracing individual items in batch processing
- ✅ Conditional spans - Dynamic span creation based on runtime conditions
- ✅ Non-function blocks - Setup, cleanup, or configuration phases
- ❌ Regular functions - Use
@traceinstead
enrich_span_context() (Recommended)
Creates spans with automatic HoneyHive namespacing:
tracer.start_span() (Low-Level)
For raw OpenTelemetry-style control:
Comparison
| Feature | enrich_span_context() | tracer.start_span() |
|---|---|---|
| Auto namespacing | ✅ Automatic | ❌ Manual |
| HoneyHive enrichment | ✅ Built-in | ❌ Manual attributes |
| Best for | Business logic | Low-level control |
Conditional Spans
Create spans only when conditions are met:Best Practices
Span Naming
Avoid Over-Instrumentation
Related
Enriching Traces
Add metadata with enrich_span and enrich_session
Enrichment Schema
Namespaces, data types, backend attributes
Distributed Tracing
Cross-service tracing
Python SDK Reference
Full API documentation

