Class Instrumenter<REQUEST,​RESPONSE>


  • public class Instrumenter<REQUEST,​RESPONSE>
    extends Object
    An instrumenter of the start and end of a request/response lifecycle. Almost all instrumentation of libraries falls into modeling start and end, generating observability signals from these such as a tracing Span, or metrics such as the duration taken, active requests, etc. When instrumenting a library, there will generally be four steps.
    • Method Detail

      • start

        public io.opentelemetry.context.Context start​(io.opentelemetry.context.Context parentContext,
                                                      REQUEST request)
        Starts a new operation to be instrumented. The parentContext is the parent of the resulting instrumented operation and should usually be Context.current(). The request is the request object of this operation. The returned Context should be propagated along with the operation and passed to end(Context, Object, Object, Throwable) when it is finished.
      • end

        public void end​(io.opentelemetry.context.Context context,
                        REQUEST request,
                        RESPONSE response,
                        @Nullable Throwable error)
        Ends an instrumented operation. The Context must be what was returned from start(Context, Object). request is the request object of the operation, response is the response object of the operation, and error is an exception that was thrown by the operation, or null if none was thrown.