OpenFeign / feign

Feign makes writing java http clients easier
Apache License 2.0
9.51k stars 1.93k forks source link

Using ResponseInterceptor : add request execution elapsedTime to the InvocationContext #2617

Open apeigney opened 1 month ago

apeigney commented 1 month ago

I'm implementing the ResponseInterceptor interface to provide informations about each HTTP request to my users. I wanted to display the request execution elapsedTime, but this data is not present in the InvocationContext.

in ResponseHandler, this could be as simple as

public Object handleResponse(
      String configKey, Response response, Type returnType, long elapsedTime) throws Exception {
    try {
      response = logAndRebufferResponseIfNeeded(configKey, response, elapsedTime);
      return executionChain.next(
          new InvocationContext(
              configKey,
              decoder,
              errorDecoder,
              dismiss404,
              closeAfterDecode,
              decodeVoid,
              response,
              returnType,
              elapsedTime));