Skip to main content

Laminar.setSpanAttributes(attributes)

Set attributes on the current span.
await observe({ name: 'process' }, async () => {
  Laminar.setSpanAttributes({
    'document.pages': 10,
    'document.language': 'en',
  });
});
Parameters:
NameTypeDescription
attributesRecord<typeof LaminarAttributes[keyof typeof LaminarAttributes], AttributeValue>Key-value pairs
Returns: void

Laminar.setSpanOutput(output)

Explicitly set span output.
await observe({ name: 'complex_operation' }, async () => {
  const result = await doWork();
  Laminar.setSpanOutput(result.summary); // Record only the summary
  return result;
});
Parameters:
NameTypeDefaultDescription
outputanyOutput payload (JSON-serialized)
Returns: voidNote: No-op if output is null or undefined.

Laminar.setSpanTags(tags)

Set tags on the current span (deduplicated).
await observe({ name: 'process' }, async () => {
  if (input.length > 10000) {
    Laminar.setSpanTags(['long-input']);
  }
});
Parameters:
NameTypeDefaultDescription
tagsstring[]Tags to set (deduplicated)
Returns: voidNote: Laminar.addSpanTags(...) is not available in the TypeScript SDK—use setSpanTags(...).

Laminar.event(options)

Add an event to the current span, or create a span if none exists.
await observe({ name: 'workflow' }, async () => {
  Laminar.event({
    name: 'checkpoint_reached',
    attributes: { step: 5 },
  });
});
Parameters:
NameTypeDefaultDescription
options.namestringEvent name (required)
options.attributesRecord<string, AttributeValue>Event attributes
options.timestampTimeInputOTEL nowCustom timestamp
options.sessionIdstringSession ID
options.userIdstringUser ID
Returns: void

span.end(endTime?)

End a manually created span.
const span = Laminar.startSpan({ name: 'operation' });
try {
  await doWork();
} finally {
  span.end(); // Always end in finally block
}
Parameters:
NameTypeDefaultDescription
endTimeTimeInputOTEL nowEnd timestamp
Returns: voidNote: Pops active context if span was activated via startActiveSpan.

span.recordException(exception, time?)

Record an exception on the span.
const span = Laminar.startSpan({ name: 'risky_operation' });
try {
  await riskyWork();
} catch (error) {
  span.recordException(error);
  throw error;
} finally {
  span.end();
}
Parameters:
NameTypeDefaultDescription
exceptionExceptionError/exception to record
timeTimeInputOTEL nowTimestamp
Returns: void

span.setAttributes(attributes)

Set attributes directly on a span object.
const span = Laminar.startSpan({ name: 'operation' });
span.setAttributes({ 'operation.status': 'success' });
span.end();
Parameters:
NameTypeDescription
attributesSpanAttributesKey-value pairs
Returns: this