• Registers Phoenix OpenTelemetry tracing with the specified configuration.

    This function sets up a complete OpenTelemetry tracing pipeline configured to send traces to a Phoenix instance. It creates a NodeTracerProvider with appropriate span processors, resource attributes, and optional instrumentations.

    The function handles:

    • Creating and configuring a NodeTracerProvider
    • Setting up OTLP trace export to Phoenix
    • Configuring span processors (batch or simple)
    • Registering instrumentations (if provided)
    • Setting up resource attributes for project identification
    • Optional global provider registration

    Parameters

    Returns NodeTracerProvider

    The configured NodeTracerProvider instance that can be used to create traces

    Basic usage with minimal configuration:

    import { register } from '@arizeai/phoenix-otel';

    // Uses environment variables for URL and API key
    const provider = register({
    projectName: 'my-application'
    });

    Full configuration with custom settings:

    import { register } from '@arizeai/phoenix-otel';
    import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
    import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';

    const provider = register({
    projectName: 'my-web-app',
    url: 'https://app.phoenix.arize.com',
    apiKey: 'phx_1234567890abcdef',
    batch: true,
    global: true,
    instrumentations: [
    new HttpInstrumentation(),
    new ExpressInstrumentation()
    ],
    diagLogLevel: DiagLogLevel.INFO
    });

    Custom span processors:

    import { register } from '@arizeai/phoenix-otel';
    import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
    import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';

    const exporter = new OTLPTraceExporter({
    url: 'https://app.phoenix.arize.com/v1/traces',
    headers: { 'Authorization': 'Bearer your-api-key' }
    });

    const provider = register({
    projectName: 'my-app',
    spanProcessors: [new BatchSpanProcessor(exporter)],
    global: false // Manual provider management
    });

    Debugging configuration:

    const provider = register({
    projectName: 'debug-app',
    url: 'http://localhost:6006',
    batch: false, // Immediate span export for debugging
    diagLogLevel: DiagLogLevel.DEBUG
    });