Class GenAiSpans

java.lang.Object
org.mockserver.telemetry.GenAiSpans

public final class GenAiSpans extends Object
Static emit point for explicit GenAI semantic-convention spans describing the LLM completions MockServer serves. A process-wide holder (like the metrics gauges) so the action handler can record a span without threading a tracer through its constructors.

No-op unless GenAiSpanExporter has installed a tracer (i.e. unless mockserver.otelTracesEnabled is set). These are spans MockServer codes deliberately — there is no auto-instrumentation. Fail-soft: any error while recording is swallowed so telemetry never affects responses.

  • Method Details

    • isEnabled

      public static boolean isEnabled()
      True if span emission is currently active.
    • recordCompletion

      public static void recordCompletion(Provider provider, String model, Completion completion)
      Emit one GenAI span for a served completion, following the OpenTelemetry GenAI semantic conventions (gen_ai.*). No-op when disabled.