- TypeScript
- Python
observe(options, fn, …args)
Wrap a function to create a span. Automatically captures inputs, outputs, and errors.| Name | Type | Default | Description |
|---|---|---|---|
name | string | fn.name | Span name |
sessionId | string | — | Associate trace with session |
userId | string | — | Associate trace with user |
metadata | Record<string, any> | — | Trace metadata (JSON-serializable) |
tags | string[] | — | Span tags (deduplicated) |
traceType | 'DEFAULT' | 'EVALUATION' | 'DEFAULT' | Trace type |
spanType | 'DEFAULT' | 'LLM' | 'TOOL' | 'EXECUTOR' | 'EVALUATOR' | 'EVALUATION' | 'DEFAULT' | Span type |
input | any | — | Explicit input (overrides function args) |
ignoreInput | boolean | false | Don’t record input |
ignoreOutput | boolean | false | Don’t record output |
parentSpanContext | string | LaminarSpanContext | — | Parent context for distributed tracing |
rolloutEntrypoint | boolean | false | Return a wrapped function for rollout sessions instead of executing immediately |
Promise<ReturnType<F>> (default) or wrapped function when rolloutEntrypoint: trueBehavior:- If one non-Map object argument, records that object as input; otherwise records array
- Maps converted to entries, circular references become
"[Circular reference]" - Exceptions recorded via
recordExceptionand re-thrown - Anonymous function name becomes
""ifnamenot provided - Works with both sync and async functions
- When
rolloutEntrypointis true, returns a wrapped function and does not execute immediately - In rollout sessions, Laminar attaches
rollout.session_idfromLMNR_ROLLOUT_SESSION_ID
observeDecorator(config)
Class method decorator version ofobserve.observe options. Config can be an object or a function (thisArg, ...args) => config for per-call configuration.Returns: Method decorator