Skip to main content
@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.ts re-exports the helper surface from @arizeai/openinference-core
  • node_modules/@arizeai/openinference-core/src/helpers/withSpan.ts implements wrapper behavior
  • node_modules/@arizeai/openinference-core/src/helpers/wrappers.ts defines the span-kind wrappers traceChain, traceAgent, traceTool, traceLLM, traceRetriever, traceReranker, traceEmbedding, traceGuardrail, traceEvaluator, and tracePrompt
  • node_modules/@arizeai/openinference-core/src/helpers/decorators.ts defines observe

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): 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 this value

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.
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.
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.ts
  • node_modules/@arizeai/openinference-core/src/helpers/withSpan.ts
  • node_modules/@arizeai/openinference-core/src/helpers/wrappers.ts
  • node_modules/@arizeai/openinference-core/src/helpers/decorators.ts