Overview
When building complex applications, you often need to continue traces across different parts of your system:- Function boundaries where traces need to span multiple function calls
- Service boundaries where traces cross different microservices
- Async operations where traces need to be maintained across async boundaries
- Request handlers where different API endpoints handle parts of the same user journey
Passing Span Objects
The most direct way to continue traces is by passing span objects between functions.- JavaScript/TypeScript
- Python
Use
Laminar.startSpan()
and Laminar.withSpan()
to create and continue spans:Remember to call
span.end()
to complete the trace. You can also pass true
as the third argument (endOnExit
) to the last Laminar.withSpan()
call to automatically end the span.Using Span Context Serialization
When you can’t pass span objects directly (e.g., across service boundaries or through message queues), use span context serialization.LaminarSpanContext
LaminarSpanContext allows you to serialize and deserialize span context as strings, making it possible to continue traces across services.- JavaScript/TypeScript
- Python