- TypeScript
- Python
Laminar.startSpan(options)
Create a span without activating it. Use for spans you’ll pass to other functions.| Name | Type | Default | Description |
|---|---|---|---|
name | string | — | Span name (required) |
input | any | — | Span input (JSON-serialized) |
spanType | 'DEFAULT' | 'LLM' | 'TOOL' | 'DEFAULT' | Span type |
tags | string[] | — | Span tags |
userId | string | — | User ID |
sessionId | string | — | Session ID |
metadata | Record<string, any> | — | Metadata |
parentSpanContext | string | LaminarSpanContext | — | Parent context |
context | Context | — | OpenTelemetry context |
SpanNote: Not activated—caller must propagate context manually or use withSpan.Laminar.startActiveSpan(options)
Create and activate a span. Child spans nest automatically.| Name | Type | Default | Description |
|---|---|---|---|
name | string | — | Span name (required) |
input | any | — | Span input (JSON-serialized) |
spanType | 'DEFAULT' | 'LLM' | 'TOOL' | 'DEFAULT' | Span type |
tags | string[] | — | Span tags |
userId | string | — | User ID |
sessionId | string | — | Session ID |
metadata | Record<string, any> | — | Metadata |
parentSpanContext | string | LaminarSpanContext | — | Parent context |
context | Context | — | OpenTelemetry context |
LaminarSpan | SpanNote: Must call span.end() (recommend in finally block). Context push/pop handled automatically.Laminar.withSpan(span, fn, endOnExit?)
Activate an existing span for the duration of a function.| Name | Type | Default | Description |
|---|---|---|---|
span | Span | — | Span to activate |
fn | () => T | — | Function to execute |
endOnExit | boolean | false | End span when function completes |
fn (or Promise if async)Note: Records exception on error. If endOnExit is true, span ends after fn (awaited if Promise).Example: Pass span objects between functions