Class NoOpTracerHook

java.lang.Object
org.apache.juneau.rest.server.tracing.NoOpTracerHook
All Implemented Interfaces:
TracerHook

public final class NoOpTracerHook extends Object implements TracerHook
Default TracerHook implementation that opens no spans and records nothing.

Used whenever no consumer-provided TracerHook bean is reachable from the RestContext's bean store. Ensures the TracerHook contract is always satisfied — the framework can call startSpan(RestRequest) unconditionally without a null-check, and the returned NoOpTracerHook.NoOpScope satisfies the close-in-finally contract with zero allocations.

Both INSTANCE and NoOpTracerHook.NoOpScope.INSTANCE are process-wide singletons; the startSpan(RestRequest) method returns the same scope reference for every call and JIT-inlines the no-op setters / close to empty method bodies.

Since:
10.0.0
  • Field Details

  • Method Details

    • startSpan

      public Scope startSpan(RestRequest request)
      Description copied from interface: TracerHook
      Opens a new span for the in-flight request.
      Specified by:
      startSpan in interface TracerHook
      Parameters:
      request - The in-flight RestRequest. Never null. Bridges may read headers for distributed-tracing context propagation (e.g. W3C traceparent / tracestate), the HTTP method, the path, etc. Bridges must not mutate the request.
      Returns:
      The opened Scope. Never null. Returning null is a contract violation — bridges that cannot open a span (e.g. because the trace context is invalid) should return NoOpTracerHook.NoOpScope.INSTANCE so the framework's close-in-finally contract still holds.