• Creates a default span processor configured for Phoenix OpenTelemetry tracing.

    This function creates an appropriate span processor (batch or simple) based on the provided configuration parameters. It handles URL normalization, header configuration, and API key authentication automatically.

    The function will:

    • Normalize the collector URL to include the /v1/traces endpoint if needed
    • Configure authentication headers using the provided API key
    • Merge any additional custom headers
    • Create either a batch or simple span processor based on the batch parameter

    Parameters

    • params: Pick<RegisterParams, "url" | "apiKey" | "batch" | "headers">

      Configuration parameters for the span processor

      • url

        The URL to the Phoenix server (will be normalized to include /v1/traces)

      • apiKey

        The API key for authenticating with the Phoenix instance

      • headers

        Additional headers to include in OTLP requests

      • batch

        Whether to use batching for span processing (recommended for production)

    Returns SpanProcessor

    A configured SpanProcessor instance ready for use with a NodeTracerProvider

    Basic usage with environment variables:

    const processor = getDefaultSpanProcessor({
    batch: true
    });

    Full configuration with custom settings:

    const processor = getDefaultSpanProcessor({
    url: 'https://app.phoenix.arize.com',
    apiKey: 'phx_1234567890abcdef',
    headers: { 'x-custom-header': 'value' },
    batch: true
    });

    Debugging configuration with immediate export:

    const processor = getDefaultSpanProcessor({
    url: 'http://localhost:6006',
    batch: false // Immediate span export for debugging
    });

    Using with custom headers:

    const processor = getDefaultSpanProcessor({
    url: 'https://app.phoenix.arize.com',
    apiKey: 'your-api-key',
    headers: {
    'x-api-version': '1.0',
    'x-client-name': 'my-app'
    },
    batch: true
    });