Skip to main content

Available Instrumentations

OpenInference provides automatic instrumentation for popular LLM frameworks and providers in JavaScript:

OpenAI

Auto-instrument OpenAI SDK calls

LangChain

Auto-instrument LangChain.js applications

Anthropic

Auto-instrument Anthropic SDK

AWS Bedrock

Auto-instrument AWS Bedrock calls

Instrumentation Packages

Installation

Install the OpenTelemetry SDK and your chosen instrumentation:

Basic Usage

Most instrumentations use the standard OpenTelemetry registration pattern:
instrumentation.ts
Load instrumentation before importing your application code:

Manual Instrumentation Required

Some frameworks require manual instrumentation due to their module structure:

LangChain.js

LangChain must be manually instrumented:
instrumentation.ts

LangChain v0.x

For LangChain 0.x versions:
instrumentation.ts

Multiple Instrumentations

You can register multiple instrumentations simultaneously:

Configuration Options

Each instrumentation can be configured with trace config options:

Common Configuration Options

Environment Variables

Configure instrumentation behavior via environment variables:
.env

Suppressing Tracing

All instrumentations respect the OpenTelemetry isTracingSuppressed() flag:

Context Propagation

All instrumentations automatically propagate context attributes set via @arizeai/openinference-core:

Complete Example

instrumentation.ts
app.ts

Testing Instrumentations

When developing or testing instrumented applications:
  1. Use console exporter for local development:
  1. Enable debug logging to troubleshoot issues:
  1. Verify context propagation:

Best Practices

Load instrumentation first: Always load your instrumentation file before importing application code using the -r flag.
Use environment variables: Configure data masking via environment variables for flexibility across environments.
Respect suppressed tracing: When using suppressTracing(), ensure sensitive operations are not traced.
Batch exporters in production: Use BatchSpanProcessor instead of SimpleSpanProcessor for better performance:

Next Steps

Core Package

Use OITracer and context attributes

OpenAI

OpenAI-specific instrumentation docs

LangChain

LangChain-specific instrumentation docs

Examples

View complete examples