Skip to main content
Wrap functions with Laminar to capture inputs, outputs, and errors automatically.

observe(options, fn, …args)

Wrap a function to create a span. Automatically captures inputs, outputs, and errors.
Parameters:Returns: Promise<ReturnType<F>>Behavior:
  • 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 recordException and re-thrown
  • Anonymous function name becomes "" if name not provided
  • Works with both sync and async functions
Examples: Group multiple LLM calls under one parent span
Examples: Nested spans for multi-step workflows

observeDecorator(config)

Class method decorator version of observe.
Parameters: Same as observe options. Config can be an object or a function (thisArg, ...args) => config for per-call configuration.Returns: Method decorator