Class NoOpTracerHook.NoOpScope

java.lang.Object
org.apache.juneau.rest.server.tracing.NoOpTracerHook.NoOpScope
All Implemented Interfaces:
AutoCloseable, Scope
Enclosing class:
NoOpTracerHook

public static final class NoOpTracerHook.NoOpScope extends Object implements Scope
No-op Scope returned by NoOpTracerHook.

Drops every status, error, and close transition on the floor. Public so user code that wants to fall back to the no-op behaviour from a custom TracerHook (for example, when the incoming trace context is unparseable) can return INSTANCE instead of implementing a private equivalent.

  • Field Details

  • Method Details

    • setStatusCode

      public void setStatusCode(int statusCode)
      Description copied from interface: Scope
      Records the HTTP response status code on the span.

      Called by the framework after the @RestOp handler completes — before Scope.close(), and before Scope.setError(Throwable) if the handler also threw. Bridges typically translate the status into both a numeric attribute (e.g. OpenTelemetry's http.response.status_code) and an overall span status (HTTP 5xx maps to span-status ERROR; other codes map to UNSET per the OTel HTTP semantic conventions).

      Specified by:
      setStatusCode in interface Scope
      Parameters:
      statusCode - The HTTP status code (e.g. 200, 404, 500).
    • setError

      public void setError(Throwable error)
      Description copied from interface: Scope
      Records the exception (if any) the @RestOp handler threw on the span.

      Called by the framework only when the handler threw — immediately before Scope.close(). Bridges typically record the throwable as a span event with the stack trace, set the span status to ERROR, and add an exception.type attribute carrying the exception's simple-name.

      Specified by:
      setError in interface Scope
      Parameters:
      error - The exception thrown by the handler. Never null when this method is called.
    • close

      public void close()
      Description copied from interface: Scope
      Closes the span.

      Always called by the framework — via the standard finally-block contract on AutoCloseable — whether the handler returned normally or threw. Implementations must not throw checked exceptions; the close path runs in a finally where masking the original handler exception is unsafe. Implementations that need to surface bridge-level errors should log + swallow instead.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Scope