Class HttpServerTracingObservationHandler

java.lang.Object
io.micrometer.tracing.handler.HttpServerTracingObservationHandler
All Implemented Interfaces:
io.micrometer.observation.ObservationHandler<io.micrometer.observation.transport.http.context.HttpServerContext>, TracingObservationHandler<io.micrometer.observation.transport.http.context.HttpServerContext>

public class HttpServerTracingObservationHandler extends Object implements TracingObservationHandler<io.micrometer.observation.transport.http.context.HttpServerContext>
TracingRecordingListener that uses the Tracing API to record events for HTTP server side.
Since:
1.0.0
  • Constructor Details

    • HttpServerTracingObservationHandler

      public HttpServerTracingObservationHandler(Tracer tracer, HttpServerHandler handler)
      Creates a new instance of HttpServerTracingObservationHandler.
      Parameters:
      tracer - tracer
      handler - http server handler
    • HttpServerTracingObservationHandler

      public HttpServerTracingObservationHandler(Tracer tracer, Function<io.micrometer.observation.transport.http.HttpServerRequest,Span> startFunction, BiConsumer<io.micrometer.observation.transport.http.HttpServerResponse,Span> stopConsumer)
      Creates a new instance of HttpServerTracingObservationHandler.
      Parameters:
      tracer - tracer
      startFunction - function that creates a span
      stopConsumer - lambda to be applied on the span upon receiving the response
  • Method Details

    • getSpanName

      public String getSpanName(io.micrometer.observation.transport.http.context.HttpServerContext ctx)
      Description copied from interface: TracingObservationHandler
      Get the span name.
      Specified by:
      getSpanName in interface TracingObservationHandler<io.micrometer.observation.transport.http.context.HttpServerContext>
      Parameters:
      ctx - handler context
      Returns:
      name for the span
    • supportsContext

      public boolean supportsContext(io.micrometer.observation.Observation.Context context)
      Specified by:
      supportsContext in interface io.micrometer.observation.ObservationHandler<io.micrometer.observation.transport.http.context.HttpServerContext>
      Specified by:
      supportsContext in interface TracingObservationHandler<io.micrometer.observation.transport.http.context.HttpServerContext>
    • onStart

      public void onStart(io.micrometer.observation.transport.http.context.HttpServerContext ctx)
      Specified by:
      onStart in interface io.micrometer.observation.ObservationHandler<CTX extends io.micrometer.observation.transport.http.context.HttpContext>
    • getTracer

      public Tracer getTracer()
      Description copied from interface: TracingObservationHandler
      Returns the Tracer.
      Specified by:
      getTracer in interface TracingObservationHandler<CTX extends io.micrometer.observation.transport.http.context.HttpContext>
      Returns:
      tracer
    • onError

      public void onError(io.micrometer.observation.transport.http.context.HttpServerContext context)
      Specified by:
      onError in interface io.micrometer.observation.ObservationHandler<CTX extends io.micrometer.observation.transport.http.context.HttpContext>
      Specified by:
      onError in interface TracingObservationHandler<CTX extends io.micrometer.observation.transport.http.context.HttpContext>
    • onStop

      public void onStop(io.micrometer.observation.transport.http.context.HttpServerContext ctx)
      Specified by:
      onStop in interface io.micrometer.observation.ObservationHandler<CTX extends io.micrometer.observation.transport.http.context.HttpContext>