@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.tsdefinestraceChain,traceAgent, andtraceToolnode_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):
| 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. |
- 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 }).
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, and traceTool, 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

