Documentation Index
Fetch the complete documentation index at: https://docs.hipocap.com/llms.txt
Use this file to discover all available pages before exploring further.
Laminar.setSpanAttributes(attributes)
Set attributes on the current span.await observe({ name: 'process' }, async () => {
Laminar.setSpanAttributes({
'document.pages': 10,
'document.language': 'en',
});
});
Parameters:| Name | Type | Description |
|---|
attributes | Record<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:| Name | Type | Default | Description |
|---|
output | any | — | Output payload (JSON-serialized) |
Returns: voidNote: No-op if output is null or undefined.
Set tags on the current span (deduplicated).await observe({ name: 'process' }, async () => {
if (input.length > 10000) {
Laminar.setSpanTags(['long-input']);
}
});
Parameters:| Name | Type | Default | Description |
|---|
tags | string[] | — | 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:| Name | Type | Default | Description |
|---|
options.name | string | — | Event name (required) |
options.attributes | Record<string, AttributeValue> | — | Event attributes |
options.timestamp | TimeInput | OTEL now | Custom timestamp |
options.sessionId | string | — | Session ID |
options.userId | string | — | User 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:| Name | Type | Default | Description |
|---|
endTime | TimeInput | OTEL now | End 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:| Name | Type | Default | Description |
|---|
exception | Exception | — | Error/exception to record |
time | TimeInput | OTEL now | Timestamp |
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:| Name | Type | Description |
|---|
attributes | SpanAttributes | Key-value pairs |
Returns: thisLaminar.set_span_attributes(attributes)
Set attributes on the current span.@observe()
def process_document(doc):
Laminar.set_span_attributes({
"document.pages": len(doc.pages),
"document.language": doc.detected_language,
})
Parameters:| Name | Type | Description |
|---|
attributes | dict[Attributes or str, Any] | Key-value pairs. Keys can be Attributes enum or strings. Non-primitive values JSON-serialized. |
Returns: NoneNote: No-op if no active span.
Laminar.set_span_output(output)
Explicitly set span output.@observe()
def complex_operation():
result = do_many_things()
Laminar.set_span_output(result.summary) # Record only summary
return result
Parameters:| Name | Type | Default | Description |
|---|
output | Any | None | Output value (JSON-serialized, truncated if >10MB) |
Returns: NoneNote: No-op if no active span.
Set tags on the current span (deduplicated).@observe()
def process_input(text: str):
if len(text) > 10000:
Laminar.set_span_tags(["long-input"])
Parameters:| Name | Type | Description |
|---|
tags | list[str] | Tags to set (deduplicated) |
Returns: None
Add (union) tags onto the current span.@observe()
def process_input(text: str):
if len(text) > 10000:
Laminar.add_span_tags(["long-input"])
Parameters:| Name | Type | Description |
|---|
tags | list[str] | Tags to add |
Returns: NoneNote: Warns if not list[str].
Laminar.event(name, attributes=None, timestamp=None, *, user_id=None, session_id=None)
Add an event to the active span (creates and ends a span if none is active).from lmnr import Laminar, observe
@observe()
def workflow():
Laminar.event("checkpoint_reached", attributes={"step": 5})
Parameters:| Name | Type | Default | Description |
|---|
name | str | — | Event name |
attributes | dict[str, AttributeValue] | None | None | Event attributes |
timestamp | datetime | int | None | None | Timestamp (defaults to OTEL now) |
user_id | str | None | None | User ID |
session_id | str | None | None | Session ID |
Returns: None
span.end(end_time=None)
End a manually created span.span = Laminar.start_span(name="operation")
try:
do_work()
finally:
span.end() # Always end in finally block
Parameters:| Name | Type | Default | Description |
|---|
end_time | int | None | None | End timestamp (defaults to OTEL now) |
Returns: None
span.record_exception(exception, attributes=None, timestamp=None, escaped=False)
Record an exception on the span.with Laminar.start_as_current_span(name="risky_operation") as span:
try:
risky_work()
except Exception as e:
span.record_exception(e)
raise
Parameters:| Name | Type | Default | Description |
|---|
exception | BaseException | — | Exception to record |
attributes | dict[str, AttributeValue] | None | None | Additional exception attributes |
timestamp | int | None | None | Timestamp (defaults to OTEL now) |
escaped | bool | False | Mark as escaped exception |
Returns: None
span.set_attributes(attributes)
Set many attributes directly on a span object.span.set_attributes({
"operation.status": "success",
"operation.items_count": 42,
})
Parameters:| Name | Type | Description |
|---|
attributes | dict[str, AttributeValue] | Key-value pairs |
Returns: None
span.set_attribute(key, value)
Set a single attribute on a span object.span.set_attribute("operation.status", "success")
Parameters:| Name | Type | Description |
|---|
key | str | Attribute key |
value | AttributeValue | Attribute value |
Returns: None