Interface ServiceCallInstrumentation

  • 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 ServiceCallInstrumentation
    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​(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. E.g. in server side when the read message failed, write back failed etc. onComplete(double, PServiceCall, PServiceCall) will NOT be called after the exception call, but will be chained if this method has no override.
        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.