@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.
SpanTraceOptions):
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
AlongsidetraceChain, 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.
These wrappers are marked
@experimental in @arizeai/openinference-core and may change in a future release.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.
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 incontext.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

