Class RequestSpans

java.lang.Object
org.mockserver.telemetry.RequestSpans

public final class RequestSpans extends Object
Static emit point for request-level OpenTelemetry spans describing HTTP request/response handling by MockServer. Mirrors GenAiSpans in structure: a process-wide volatile tracer holder, fail-soft recording, and no-op when disabled.

No-op unless GenAiSpanExporter has installed a tracer (i.e. unless mockserver.otelTracesEnabled is set). 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.
    • recordRequest

      public static void recordRequest(String method, String path, Integer statusCode, String expectationId, long responseTimeMs, W3CTraceContext parentContext)
      Emit one SERVER span for a served HTTP request. No-op when disabled.
      Parameters:
      method - HTTP method (e.g. "GET", "POST")
      path - request path (matched expectation path or raw request path)
      statusCode - response status code, or null if unknown
      expectationId - the matched expectation ID, or null if none matched
      responseTimeMs - wall-clock response time in milliseconds (0 if unavailable)
      parentContext - parsed W3C trace context from the inbound request, or null