@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() - 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()
Quick Start
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:
@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
| Option | Description |
|---|---|
projectName | Phoenix project name attached to exported spans. Defaults to default. |
url | Phoenix base URL or full collector endpoint. The package appends /v1/traces when needed. |
apiKey | API key sent as a bearer token. Falls back to PHOENIX_API_KEY. |
headers | Additional OTLP headers merged with the auth header. |
batch | true for batched export, false for immediate export during debugging. |
instrumentations | OpenTelemetry instrumentations to register with the provider. |
spanProcessors | Custom span processors. When provided, these replace the default Phoenix exporter setup. |
global | Whether to attach the provider to the global OpenTelemetry APIs automatically. |
diagLogLevel | OpenTelemetry diagnostic logging level. |
Environment Variables
| Variable | Use |
|---|---|
PHOENIX_COLLECTOR_ENDPOINT | Base Phoenix collector URL or full OTLP trace endpoint. |
PHOENIX_API_KEY | API key used when you do not pass apiKey explicitly. |
Instrumentation
Pass OpenTelemetry instrumentations toregister() 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
Keepbatch: 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.Custom Span Processors
If you need full control over export, pass your ownspanProcessors. This replaces the default Phoenix exporter setup.
Troubleshooting
When traces do not show up in Phoenix, check these common issues:- confirm
projectNameis the project you are inspecting - confirm
urlorPHOENIX_COLLECTOR_ENDPOINTpoints at the collector - confirm
PHOENIX_API_KEYis 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
| Category | Exports |
|---|---|
| Registration | register(), attachGlobalTracerProvider(), detachGlobalTracerProvider(), createNoOpProvider() |
| Tracing helpers | withSpan(), traceChain(), traceAgent(), traceTool(), observe() |
| Context attributes | setSession(), setUser(), setMetadata(), setTags(), setPromptTemplate(), setAttributes(), getAttributesFromContext() |
| Attribute builders | getLLMAttributes(), getToolAttributes(), getRetrieverAttributes(), getEmbeddingAttributes(), getMetadataAttributes() |
| Redaction and safety | OITracer, withSafety(), safelyJSONStringify(), safelyJSONParse() |
| Semantic conventions | SemanticConventions, OpenInferenceSpanKind, MimeType |
| OpenTelemetry | trace, context, SpanStatusCode, DiagLogLevel, suppressTracing, registerInstrumentations() |
| Types | Tracer, Instrumentation, SpanTraceOptions, RegisterParams |
Where To Start
- Tracing helpers for wrapping functions with
withSpan,traceChain,traceAgent,traceTool, andobserve - 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
Source Map
src/index.tsexports the package surfacesrc/register.tsimplements provider setup and global attachment helperssrc/config.tsreads Phoenix environment variablessrc/createNoOpProvider.tsprovides a no-op provider for detached statespackage.jsondeclares the bundled docs and the@arizeai/openinference-coredependency

