Skip to main content

@arizeai/phoenix-otel re-exports the OpenTelemetry trace, context, and SpanStatusCode APIs, plus the @arizeai/openinference-core attribute builders, OITracer, and utility helpers.

For most use cases, prefer the tracing helpers covered in Tracing Helpers. Use manual spans when you need exact span timing, low-level OpenTelemetry interop, or explicit control over which attributes are recorded.

If you do not need low-level OpenTelemetry control, use the helper wrappers first:

Raw OpenTelemetry Spans#

Use raw spans when you need full control over timing and attributes:

If you need context-propagated session, user, metadata, or prompt-template attributes on a plain tracer span, copy them explicitly with getAttributesFromContext() as shown on Context Attributes.

Attribute Helper APIs#

Use the attribute helpers to build OpenInference-compatible attribute sets for LLM, retriever, embedding, tool, input, and output spans.

Common helpers:

  • getLLMAttributes
  • getEmbeddingAttributes
  • getRetrieverAttributes
  • getToolAttributes
  • getMetadataAttributes
  • getInputAttributes
  • getOutputAttributes
  • defaultProcessInput
  • defaultProcessOutput

Trace Config And Redaction#

OITracer wraps an OpenTelemetry tracer and applies OpenInference trace masking rules before attributes are written. It also merges propagated context attributes automatically.

You can also configure masking via environment variables:

  • OPENINFERENCE_HIDE_INPUTS
  • OPENINFERENCE_HIDE_OUTPUTS
  • OPENINFERENCE_HIDE_INPUT_MESSAGES
  • OPENINFERENCE_HIDE_OUTPUT_MESSAGES
  • OPENINFERENCE_HIDE_INPUT_IMAGES
  • OPENINFERENCE_HIDE_INPUT_TEXT
  • OPENINFERENCE_HIDE_OUTPUT_TEXT
  • OPENINFERENCE_HIDE_EMBEDDING_VECTORS
  • OPENINFERENCE_BASE64_IMAGE_MAX_LENGTH
  • OPENINFERENCE_HIDE_PROMPTS
  • OPENINFERENCE_HIDE_LLM_TOOLS

Utility Helpers#

The package also re-exports small safety utilities:

  • withSafety({ fn, onError? }) wraps a function and returns null if it throws
  • safelyJSONStringify(value) wraps JSON.stringify
  • safelyJSONParse(value) wraps JSON.parse