Package org.apache.juneau.rest.server.tracing
juneau-rest-server — per-request span hook backed by a
caller-supplied TracerHook bean.
Opt-in
The SPI is off by default. A fresh RestContext built without any
@Bean TracerHook entry uses NoOpTracerHook
— no tracer is reached for, no trace-context headers are parsed, no spans are opened. Consumers
opt in by supplying a bridge implementation:
juneau-rest-server-tracing-otelshipsOtelTracerHookbacked by anio.opentelemetry.api.OpenTelemetryinstance — per-request span creation, OTel HTTP semantic-convention attributes, and W3Ctraceparent/tracestatecontext propagation.- Custom tracers (Brave, application-specific span beans, etc.) can implement
TracerHookdirectly — the SPI intentionally has no OpenTelemetry dependency on the core surface.
Lifecycle
For every @RestOp invocation, the framework opens a Scope
via startSpan(...) immediately before
parameter resolution and closes it in a finally block after the handler returns or throws.
Status code and exception are reported via Scope.setStatusCode(int)
and Scope.setError(java.lang.Throwable) before Scope.close().
TraceContextCarrier moved to juneau-rest-common
(org.apache.juneau.http.tracing) so both REST server and REST client modules share one
neutral carrier type. Server-only tracing SPI types (TraceContextExtractor,
TraceOperation, TraceContexts) remain in this package.
See Also:
- Since:
- 10.0.0
-
ClassDescriptionDefault
TracerHookimplementation that opens no spans and records nothing.No-opScopereturned byNoOpTracerHook.Handle to one in-flightTracerHook-managed span.SPI for recognizing a non-HTTP trace-context carrier inside a resolved@RestOpinvocation.Writes the W3C Trace Context response headers (traceparentand, when present,tracestate) so a client calling this server can read the resulting trace identifiers back off the response.Neutral, dependency-free helper for stamping a caller's current trace context into an arbitraryTraceContextCarrier.Immutable, low-cardinality description of the operation aTracerHookbridge should name a span after, supplied toTracerHook.startSpan(org.apache.juneau.rest.server.RestRequest, TraceContextCarrier, TraceOperation)alongside the extractedTraceContextCarrier.SPI for receiving per-request tracing events fromjuneau-rest-server.