Interface PServiceCallInstrumentation

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface PServiceCallInstrumentation
    Interface handling the instrumentation of service calls.
    • Field Detail

      • NS_IN_MILLIS

        static final long NS_IN_MILLIS
        Handy constant for calculating MS duration.
    • Method Detail

      • onComplete

        void onComplete​(double duration,
                        @Nullable
                        PServiceCall call,
                        @Nullable
                        PServiceCall reply)
        After each service call this method is called with the duration, call and response objects. Exceptions from the call is ignored, and will not affect the response in any way.

        Note that the timing may not include the whole stack time since receiving the first packet, that is dependent on the specific implementation and the limitations there. E.g. it does not include the time receiving the first HTTP packet with the headers, or waiting for free worker threads when using ProvidenceServlet.

        Parameters:
        duration - The duration of handling the service call in milliseconds, including receiving and sending it.
        call - The call triggered.
        reply - The reply returned.
      • onTransportException

        default void onTransportException​(@Nonnull
                                          java.lang.Exception e,
                                          double duration,
                                          @Nullable
                                          PServiceCall call,
                                          @Nullable
                                          PServiceCall reply)
        Called when the service call failed in the transport layer itself with something not related to the actual service call. The attempted call will be provided if known. When this method is called, then some part of the service call did not complete either inward (e.g. invalid call definition), or outward (e.g. network errors).
        Parameters:
        e - The exception thrown.
        duration - The duration of handling the service call in milliseconds, including receiving and sending it.
        call - The service call.
        reply - The service reply.