Package org.apache.juneau.rest.server.tracing


package org.apache.juneau.rest.server.tracing
Tracing SPI for 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-otel ships OtelTracerHook backed by an io.opentelemetry.api.OpenTelemetry instance — per-request span creation, OTel HTTP semantic-convention attributes, and W3C traceparent / tracestate context propagation.
  • Custom tracers (Brave, application-specific span beans, etc.) can implement TracerHook directly — 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