Class ObservationService

All Implemented Interfaces:
Unwrappable, HttpService, Service<HttpRequest,HttpResponse>

@UnstableApi public final class ObservationService extends SimpleDecoratingHttpService
Decorates an HttpService to trace inbound HttpRequests using Micrometer Observation. The following may be a typical implementation using a brave implementation:

 // create a tracer
 BraveCurrentTraceContext braveCurrentTraceContext = new BraveCurrentTraceContext(
   tracing.currentTraceContext());
 BravePropagator bravePropagator = new BravePropagator(tracing);
 BraveTracer braveTracer = new BraveTracer(tracing.tracer(), braveCurrentTraceContext,
                                           new BraveBaggageManager());

 // add tracing handlers
 List<TracingObservationHandler<?>> tracingHandlers =
   Arrays.asList(new PropagatingSenderTracingObservationHandler<>(braveTracer, bravePropagator),
                 new PropagatingReceiverTracingObservationHandler<>(braveTracer, bravePropagator),
                 new DefaultTracingObservationHandler(braveTracer));

 // create a registry
 ObservationRegistry observationRegistry = ObservationRegistry.create();

 // add the tracing handlers
 observationRegistry.observationConfig().observationHandler(
         new FirstMatchingCompositeObservationHandler(tracingHandlers));

 // add the decorator
 Server.builder()
       .decorator(ObservationService.newDecorator(observationRegistry))
 ...
 
See Also: