The automatic wrappers handle LLM providers, but many real-world workflows involve operations that are not direct LLM calls — document retrieval, embedding pipelines, custom model APIs, and post-generation evaluation.Documentation Index
Fetch the complete documentation index at: https://docs.lumiqtrace.com/llms.txt
Use this file to discover all available pages before exploring further.
startSpan lets you create a custom span for any of these, with the same trace context propagation as wrapped LLM calls.
When to use manual spans
UsestartSpan when you want to trace:
- RAG pipelines — measure retrieval latency and track retrieved context separately from the LLM call
- Custom model wrappers — a self-hosted model or a provider not covered by a built-in wrapper
- Evaluation harnesses — attach faithfulness, relevance, or custom metric scores to a span
- Multi-step workflows — break a complex pipeline into named segments for easier debugging
Basic usage
startSpan returns an object with a span handle and a run helper. Call span.end() in a finally block to guarantee the span is always closed.
startSpan options
Name of the operation. Appears as the span label in the trace flame graph.
Model identifier, if applicable. Use the exact model string (e.g.
"text-embedding-3-small") so cost estimates work correctly.Provider name, e.g.
"openai", "anthropic", "custom". Used for grouping in the provider breakdown view.Span kind hint. Accepts
"llm", "tool", "agent", "retriever", "general". Defaults to "general" when called outside a withAgent block.span methods
span.setEvalScore(name, value)
Attaches a named numeric score to the span. Scores appear in the evaluations tab and can be trended over time.
setEvalScore any number of times before span.end(). All scores are sent together when the span closes.
span.end(options)
Closes the span and enqueues the event. Must be called exactly once.
Outcome of the operation. Accepted values:
"success", "error", "timeout", "rate_limited", "cancelled".Number of input/prompt tokens consumed. Used for cost calculation.
Number of output/completion tokens generated.
Actual cost in USD, if known. Overrides any computed cost estimate.
Error description when
status is "error". Truncated to 500 characters.Propagating context to nested calls
Use therun helper returned by startSpan to run a function inside the span’s context. Wrapped LLM calls made inside run automatically link to this span as their parent.