Skip to main content

Overview

The @arizeai/openinference-core package provides the foundational utilities for OpenInference JavaScript tracing:
  • OITracer: OpenTelemetry tracer wrapper with data masking
  • Context Attributes: Session ID, user ID, metadata, and tags propagation
  • Span Wrappers: withSpan, traceChain, traceAgent, traceTool
  • Decorators: @observe for class methods
  • Attribute Helpers: Functions to generate OpenInference-compliant attributes

Installation

OITracer

OITracer wraps an OpenTelemetry tracer and can redact sensitive data before writing spans.

Basic Usage

TraceConfig Options

Environment Variables

Configure masking via environment variables:

Context Attributes

Propagate request-level attributes across all spans in a context.

Available Setters

Context Setter Reference

Retrieving Attributes

Span Wrappers

withSpan

Wrap a function to automatically create spans:

withSpan Options

Custom Input/Output Processing

Convenience Wrappers

These wrappers set the span kind automatically:

Decorators

The @observe decorator traces class methods (requires TypeScript 5+ standard decorators):

Decorator Options

Attribute Helpers

Generate OpenInference-compliant attributes:

getLLMAttributes

getLLMAttributes Parameters

getEmbeddingAttributes

getRetrieverAttributes

getToolAttributes

getInputAttributes / getOutputAttributes

getMetadataAttributes

Utility Functions

withSafety

Wrap a function and return null on error:

safelyJSONStringify / safelyJSONParse

Complete Example

Next Steps

Semantic Conventions

Learn about OpenInference semantic conventions

Instrumentations

Auto-instrument LLM frameworks

Examples

View complete examples