Arize Phoenix TS
    Preparing search index...
    • Experimental

      Wraps a function with tracing capabilities, specifically marking it as an EVALUATOR span.

      This is a convenience function that wraps withSpan with the OpenInference span kind pre-configured to EVALUATOR. Evaluator spans represent operations that assess or score the quality of an LLM application's output, such as relevance scoring, correctness checks, or LLM-as-a-judge evaluations.

      This API is experimental and may change in future versions

      Type Parameters

      • Fn extends AnyFn

        The function type being wrapped, preserving original signature

      Parameters

      • fn: Fn

        The function to wrap with EVALUATOR span tracing

      • Optionaloptions: Omit<SpanTraceOptions<AnyFn>, "kind">

        Configuration options for tracing behavior (excluding kind)

        • tracer

          Custom OpenTelemetry tracer instance (otherwise the current global tracer provider is resolved when the wrapper is invoked)

        • name

          Custom span name (defaults to function name)

        • openTelemetrySpanKind

          OpenTelemetry span kind (defaults to INTERNAL)

        • processInput

          Custom function to process input arguments into attributes

        • processOutput

          Custom function to process output values into attributes

        • attributes

          Base attributes to be added to every span created

      Returns Fn

      A wrapped function with identical signature that creates EVALUATOR spans during execution

      // Trace an LLM-as-a-judge evaluation
      const evaluateAnswer = async (question: string, answer: string) => {
      return await judge.score({ question, answer });
      };
      const tracedEvaluator = traceEvaluator(evaluateAnswer, { name: "answer-evaluation" });