@arizeai/phoenix-otel re-exports the OpenInference tracing helpers from @arizeai/openinference-core, so you can configure Phoenix export and author traced functions from one package path.
Relevant Source Files
src/index.tsre-exports the helper surface from@arizeai/openinference-corenode_modules/@arizeai/openinference-core/src/helpers/withSpan.tsimplements wrapper behaviornode_modules/@arizeai/openinference-core/src/helpers/wrappers.tsdefines the span-kind wrapperstraceChain,traceAgent,traceTool,traceLLM,traceRetriever,traceReranker,traceEmbedding,traceGuardrail,traceEvaluator, andtracePromptnode_modules/@arizeai/openinference-core/src/helpers/decorators.tsdefinesobserve
Why These Re-Exports Matter#
@arizeai/phoenix-otel adds Phoenix registration and export. The tracing helpers themselves come from @arizeai/openinference-core.
Those helpers resolve the default tracer when the wrapped function is invoked, not when the wrapper is created. That means:
- functions wrapped at module load continue following later global provider changes
- experiment-scoped providers still receive spans from previously defined helpers
- you can keep using the same wrappers when moving between standalone tracing and experiment workflows
API Reference#
withSpan(fn, options?)#
The general-purpose wrapper. All other helper wrappers build on it.
Options (SpanTraceOptions):
| Field | Type | Default | Description |
|---|---|---|---|
name | string | fn.name | Span name. Falls back to the function name. |
kind | OpenInferenceSpanKind | CHAIN | OpenInference span kind such as CHAIN, AGENT, TOOL, LLM, or RETRIEVER. |
tracer | Tracer | default tracer | Override the tracer instance. When omitted, the default tracer is resolved when the wrapper runs. |
attributes | Attributes | — | Base attributes merged into every span. |
processInput | (...args) => Attributes | defaultProcessInput | Custom function to extract span attributes from input arguments. |
processOutput | (result) => Attributes | defaultProcessOutput | Custom function to extract span attributes from the return value. |
openTelemetrySpanKind | SpanKind | SpanKind.INTERNAL | Underlying OpenTelemetry span kind. |
Behavior:
- wraps both sync and async functions
- records input and output attributes automatically
- records exceptions, marks the span as
ERROR, closes the span, and re-throws - preserves the call-time
thisvalue
traceChain(fn, options?)#
Shorthand for withSpan(fn, { ...options, kind: OpenInferenceSpanKind.CHAIN }).
traceAgent(fn, options?)#
Shorthand for withSpan(fn, { ...options, kind: OpenInferenceSpanKind.AGENT }).
traceTool(fn, options?)#
Shorthand for withSpan(fn, { ...options, kind: OpenInferenceSpanKind.TOOL }).
Additional Span-Kind Wrappers#
Alongside traceChain, traceAgent, and traceTool, the following wrappers cover the remaining OpenInference span kinds. Each is a shorthand for withSpan(fn, { ...options, kind }) with the listed span kind pre-configured, accepts the same SpanTraceOptions (minus kind), and resolves the default tracer at invocation time.
@experimental in @arizeai/openinference-core and may change in a future release.| Wrapper | Span kind | Use it for |
|---|---|---|
traceLLM(fn, options?) | LLM | Invocations of a large language model — chat or text completions and other foundation-model inference calls. |
traceRetriever(fn, options?) | RETRIEVER | Fetching documents or context from a knowledge base, vector store, or search index (RAG). |
traceReranker(fn, options?) | RERANKER | Reordering or scoring candidate documents by relevance before passing them to a model. |
traceEmbedding(fn, options?) | EMBEDDING | Converting text or other data into vector representations for semantic search and retrieval. |
traceGuardrail(fn, options?) | GUARDRAIL | Safety, validation, or policy checks such as content moderation, PII detection, or compliance enforcement. |
traceEvaluator(fn, options?) | EVALUATOR | Assessing or scoring output quality — relevance scoring, correctness checks, or LLM-as-a-judge evaluations. |
tracePrompt(fn, options?) | PROMPT | Constructing, rendering, or templating a prompt before it is sent to a model. |
observe(options?)#
Decorator factory for class methods. Use TypeScript 5+ standard decorators.
observe preserves method this context and uses the method name as the default span name unless you pass name.
Input / Output Processing#
By default, withSpan serializes function arguments into input.value and the return value into output.value. Override this with processInput and processOutput when you want richer OpenInference attributes.
The same customization pattern works with every span-kind wrapper (traceChain, traceAgent, traceTool, traceLLM, traceRetriever, traceReranker, traceEmbedding, traceGuardrail, traceEvaluator, and tracePrompt), since they all delegate to withSpan.
Combining Helpers With Context Attributes#
Tracing helpers compose naturally with context attributes. Wrap a call in context.with() to propagate session IDs, metadata, or tags to all child spans.
Use With Experiments#
When you run experiments with @arizeai/phoenix-client, the experiment framework can attach a per-run global provider. Because the wrappers resolve the default tracer at invocation time, traced functions defined at module scope still route spans to the active provider.
Source Map
src/index.tsnode_modules/@arizeai/openinference-core/src/helpers/withSpan.tsnode_modules/@arizeai/openinference-core/src/helpers/wrappers.tsnode_modules/@arizeai/openinference-core/src/helpers/decorators.ts

