Skip to main content

@arizeai/phoenix-otel is the Phoenix-focused OpenTelemetry package for Node.js. It handles provider setup, OTLP export, and instrumentation registration, then re-exports the full @arizeai/openinference-core helper surface and OpenInference semantic conventions from the same package path.

Install#

Install the package and any OpenTelemetry instrumentations you want to use with it.

Add Instrumentations#

What This Package Includes#

@arizeai/phoenix-otel combines Phoenix registration with OpenInference authoring APIs:

  • Phoenix registration: register(), attachGlobalTracerProvider(), detachGlobalTracerProvider(), createNoOpProvider()
  • OpenInference wrappers: withSpan(), traceChain(), traceAgent(), traceTool(), traceLLM(), traceRetriever(), traceReranker(), traceEmbedding(), traceGuardrail(), traceEvaluator(), tracePrompt()
  • decorators and context propagation: observe(), setSession(), setUser(), setMetadata(), setTags(), setPromptTemplate(), setAttributes()
  • attribute builders: getLLMAttributes(), getRetrieverAttributes(), getEmbeddingAttributes(), getToolAttributes(), getMetadataAttributes(), getInputAttributes(), getOutputAttributes(), defaultProcessInput(), defaultProcessOutput()
  • redaction and safety helpers: OITracer, withSafety, safelyJSONStringify, safelyJSONParse
  • OpenTelemetry utilities: trace, context, SpanStatusCode, DiagLogLevel, registerInstrumentations()

The re-exported OpenInference wrappers resolve the default tracer when the wrapped function runs, so module-scoped traced helpers continue following global provider changes.

Quick Start#

If you want raw control over span shape, switch to withSpan() or the OpenTelemetry trace API. The package docs linked below cover both patterns.

Docs And Source In node_modules#

After install, a coding agent can inspect the installed package directly:

Because @arizeai/phoenix-otel re-exports @arizeai/openinference-core, the dependency docs are also high-value local references:

Configuration#

register() can use explicit options, environment variables, or both. If you pass a Phoenix base URL, the package normalizes it to the OTLP collector endpoint at /v1/traces.

Environment-Driven Setup#

Explicit Setup#

Key Options#

OptionDescription
projectNamePhoenix project name attached to exported spans. Defaults to default.
urlPhoenix base URL or full collector endpoint. The package appends /v1/traces when needed.
apiKeyAPI key sent as a bearer token. Falls back to PHOENIX_API_KEY.
headersAdditional OTLP headers merged with the auth header.
batchtrue for batched export, false for immediate export during debugging.
instrumentationsOpenTelemetry instrumentations to register with the provider.
spanProcessorsCustom span processors. When provided, these replace the default Phoenix exporter setup.
globalWhether to attach the provider to the global OpenTelemetry APIs automatically.
diagLogLevelOpenTelemetry diagnostic logging level.

Environment Variables#

VariableUse
PHOENIX_COLLECTOR_ENDPOINTBase Phoenix collector URL or full OTLP trace endpoint.
PHOENIX_API_KEYAPI key used when you do not pass apiKey explicitly.

Instrumentation#

Vercel AI SDK (v7+)#

AI SDK v7 telemetry registration is process-global, so configure it explicitly in your application. Install ai and @ai-sdk/otel; the bundled @arizeai/openinference-vercel span processors then translate the emitted spans to OpenInference before export.

  • call registerTelemetry() only once during application startup
  • compose this integration with any logging, metrics, or custom integrations your application already registers
  • AI SDK v6 and older emit a different span shape; use @arizeai/phoenix-otel 1.x for AI SDK v6

OpenTelemetry Instrumentations#

Pass OpenTelemetry instrumentations to register() to capture framework and library activity automatically.

  • registerInstrumentations() is also re-exported for manual setups
  • auto-instrumentation works best when initialized very early in process startup
  • ESM projects often need manual library instrumentation rather than loader-based auto-instrumentation

Production#

Enable Batch Processing#

Keep batch: true in production. The batch span processor groups spans before export, reducing request volume and export overhead. Disable batching only when you need immediate local feedback.

Provider Lifecycle#

Flush and shut down the provider before process exit, otherwise in-flight batches can be lost.

For short-lived processes such as scripts, CLI commands, and serverless handlers:

Custom Span Processors#

If you need full control over export, pass your own spanProcessors. This replaces the default Phoenix exporter setup.

Troubleshooting#

When traces do not show up in Phoenix, check these common issues:

  • confirm projectName is the project you are inspecting
  • confirm url or PHOENIX_COLLECTOR_ENDPOINT points at the collector
  • confirm PHOENIX_API_KEY is present for authenticated environments
  • confirm registration happens before the instrumented work starts
  • call await provider.shutdown() before process exit when using batched export

Enable Diagnostic Logging#

Package Surface#

CategoryExports
Registrationregister(), attachGlobalTracerProvider(), detachGlobalTracerProvider(), createNoOpProvider()
Tracing helperswithSpan(), traceChain(), traceAgent(), traceTool(), traceLLM(), traceRetriever(), traceReranker(), traceEmbedding(), traceGuardrail(), traceEvaluator(), tracePrompt(), observe()
Context attributessetSession(), setUser(), setMetadata(), setTags(), setPromptTemplate(), setAttributes(), getAttributesFromContext()
Attribute buildersgetLLMAttributes(), getToolAttributes(), getRetrieverAttributes(), getEmbeddingAttributes(), getMetadataAttributes()
Redaction and safetyOITracer, withSafety(), safelyJSONStringify(), safelyJSONParse()
Semantic conventionsSemanticConventions, OpenInferenceSpanKind, MimeType
OpenTelemetrytrace, context, SpanStatusCode, DiagLogLevel, suppressTracing, registerInstrumentations()
TypesTracer, Instrumentation, SpanTraceOptions, RegisterParams

Where To Start#

  • Tracing helpers for wrapping functions with withSpan, the span-kind wrappers (traceChain, traceAgent, traceTool, traceLLM, traceRetriever, traceReranker, traceEmbedding, traceGuardrail, traceEvaluator, tracePrompt), and observe
  • Context attributes for propagating sessions, users, metadata, tags, prompt templates, and manual context propagation
  • Manual spans for raw OpenTelemetry spans, attribute builders, OITracer, and utility helpers