Arize Phoenix TS
    Preparing search index...
    • Normalizes a Phoenix server URL to ensure it includes the correct OTLP traces endpoint.

      This utility function ensures that any Phoenix server URL is properly formatted to include the /v1/traces endpoint required for OTLP trace export. It handles various URL formats and automatically appends the endpoint if missing.

      The function:

      • Checks if the URL already contains /v1/traces
      • If missing, appends /v1/traces to the base URL
      • Returns a properly formatted URL string
      • Assumes HTTP over gRPC protocol for OTLP communication

      Parameters

      • url: string

        The base URL to the Phoenix server (may or may not include the traces endpoint)

      Returns string

      A normalized URL string that includes the /v1/traces endpoint

      URL without traces endpoint:

      const normalized = ensureCollectorEndpoint('https://app.phoenix.arize.com');
      // Returns: 'https://app.phoenix.arize.com/v1/traces'

      URL that already includes traces endpoint:

      const normalized = ensureCollectorEndpoint('https://app.phoenix.arize.com/v1/traces');
      // Returns: 'https://app.phoenix.arize.com/v1/traces'

      Local development URL:

      const normalized = ensureCollectorEndpoint('http://localhost:6006');
      // Returns: 'http://localhost:6006/v1/traces'

      URL with custom port and path:

      const normalized = ensureCollectorEndpoint('https://phoenix.example.com:8080');
      // Returns: 'https://phoenix.example.com:8080/v1/traces'

      URL with existing path (edge case):

      const normalized = ensureCollectorEndpoint('https://app.phoenix.arize.com/api');
      // Returns: 'https://app.phoenix.arize.com/api/v1/traces'