Class NoOpTracerHook.NoOpScope
- All Implemented Interfaces:
AutoCloseable,Scope
- Enclosing class:
- NoOpTracerHook
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final NoOpTracerHook.NoOpScopeProcess-wide singleton instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the span.voidRecords the exception (if any) the@RestOphandler threw on the span.voidsetStatusCode(int statusCode) Records the HTTP response status code on the span.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.juneau.rest.server.tracing.Scope
recordRpcError
-
Field Details
-
INSTANCE
Process-wide singleton instance.
-
-
Method Details
-
setStatusCode
Description copied from interface:ScopeRecords the HTTP response status code on the span.Called by the framework after the
@RestOphandler completes — beforeScope.close(), and beforeScope.setError(Throwable)if the handler also threw. Bridges typically translate the status into both a numeric attribute (e.g. OpenTelemetry'shttp.response.status_code) and an overall span status (HTTP5xxmaps to span-statusERROR; other codes map toUNSETper the OTel HTTP semantic conventions).- Specified by:
setStatusCodein interfaceScope- Parameters:
statusCode- The HTTP status code (e.g.200,404,500).
-
setError
Description copied from interface:ScopeRecords the exception (if any) the@RestOphandler 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 toERROR, and add anexception.typeattribute carrying the exception's simple-name. -
close
Description copied from interface:ScopeCloses the span.Always called by the framework — via the standard
finally-block contract onAutoCloseable— whether the handler returned normally or threw. Implementations must not throw checked exceptions; the close path runs in afinallywhere masking the original handler exception is unsafe. Implementations that need to surface bridge-level errors should log + swallow instead.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceScope
-