Optionalconfig?: BufferConfigThe configuration options for processor.
Readonlyexporter: SpanExporterThe exporter to pass spans to.
Optional ReadonlypropagateContextAttributes?: booleanCopies OpenInference context attributes onto each span at start time.
The Vercel AI SDK creates its own spans, so this processor never reads the
OpenInference context the way the OpenInference instrumentors do. As a result,
values set with the @arizeai/openinference-core helpers — setSession,
setUser, setMetadata, setTags — never reach the exported AI spans.
When enabled, every OpenInference attribute (session.id, user.id, metadata.*,
tag.tags, …) present on the start-time context is written directly onto the span,
so e.g. a session.id set via
context.with(setSession(context.active(), { sessionId }), () => streamText(...))
groups the trace into a session in Arize / Phoenix. Setting them at start time means
children started in the same context inherit them, and the values survive
reparentOrphanedSpans and export.
Optional ReadonlyreparentOrphanedSpans?: booleanReparents AI spans that would be orphaned by span filtering. When a spanFilter
drops non-OpenInference spans (e.g. isOpenInferenceSpan), the highest-level AI
span (e.g. ai.generateText, ai.streamText) is often parented under a non-AI span —
such as the HTTP/server span Next.js parents everything under — which the filter
removes, leaving the AI span pointing at a parent that was never exported.
When enabled, any AI span whose direct parent is a non-AI span is detached (re-rooted) so it becomes a trace root. Handles multiple sibling AI spans per trace; AI spans nested under an AI parent are left intact. The check is stateless — the parent span is read from the start-time context.
If a re-rooted root is an AI-like span the kind map doesn't recognize (e.g. a framework
"turn"/wrapper span), it would otherwise be kind-less and dropped by the filter; it is
tagged openinference.span.kind = AGENT so it is kept as the trace root. Recognized
spans keep the kind the map gave them (e.g. ai.embed stays CHAIN); only kind-less
AI-like roots get the AGENT fallback.
Intended for use alongside a filter that drops non-AI parent spans — without such a filter the non-AI parent is still exported and reparenting would split the trace.
Optional ReadonlyspanFilter?: SpanFilterA filter to apply to spans before exporting. If it returns true for a given span, that span will be exported.
Protectedon
Extends BatchSpanProcessor to support OpenInference attributes. This processor enhances spans with OpenInference attributes before exporting them. It can be configured to selectively export only OpenInference spans or all spans.
Example