-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: additional callback methods for Interceptor interface #5025
Conversation
Added two more methods to the Interceptor interface. The main intention is to provide enough functionality to implement an HttpLoggingInterceptor compatible with every HttpClient implementation. Signed-off-by: Marc Nuri <marc@marcnuri.com>
SonarCloud Quality Gate failed. |
I'm presuming that you'll want this interceptor to be last in the chain, and that we'll log just based upon the after method - using the request from the response. This is a probably close enough to the logging users will want to see. From our perspective correlating to the incoming user level request prior to the before modifications may be interesting, but has been made hard to do because no call spans both and we don't have unique request identifiers. This also won't necessarily correlate intermediate requests by the interceptors - failed backwards compatibility and OpenShiftOAuthInterceptor token refreshes will be logged as separate requests.
Are you also looking to log the requests by the TokenRefreshInteceptor? |
I assume that users want the complete log of the HTTP conversation regardless of its origin (client request, interceptor, etc). So I guess we do want to log these requests too. TBH I didn't actually consider this scenario, but as far as composition looks, those requests should be logged too.
I'm not sure if we actually want this interceptor to be applied first instead. Anyway, the interceptor should be internal and added by us in a similar way as we are currently adding the OkHttp interceptor. So ensuring it's the first or last in the chain should be easy. The interceptor should log same as OkHttp (I haven't checked but I assume):
So probably 1-5 can be logged in the |
The TokenRefreshInteceptor creates a new client instance, which is not based upon the Configuration - it uses the plain HttpClient.Factory.newBuilder() method.
I'm unsure how easily this will be applied. Proxying the consumer will give us access to the bytes, but not the broader cycle - without additional changes you'd have to log the bytes as they are received because there is no separate notification to the consumer that we're done. |
The It would certainly be much neater to log in a continuous contextual way. I recall you mentioned some time ago that we already did add some improvements that'd allow to get better callbacks of the HTTP request/response processing events (start/.../end). I also see that we could maybe somehow leverage the Did you have something in mind? It might be more interesting to make the |
Sure, it just becomes less customizable that way.
There's no single great solution. We'd have to look at content type and length to have some understanding of what's in the response - otherwise we can't easily tell a difference at this layer between binary and test or log streaming (or other large / long running download), and just a more typical response. We'll probably have to buffer that up to a given size, then log in chunks if it looks like it's text. Yes something like onBodyDone could work:
|
OK, so shall I merge this and we can discuss the logging approach once I provide the PoC? |
Sure, that's fine. |
Description
Relates to:
mvn oc:build -Dorg.slf4j.simpleLogger.defaultLogLevel=trace
` eclipse-jkube/jkube#1950Added two more methods to the Interceptor interface. The main intention is to provide enough functionality to implement an
HttpLoggingInterceptor
compatible with everyHttpClient
implementation.The provided infrastructure will allow to implement (in a subsequent PR) an
HttpLoggingInterceptor
to replace the OkHttp-specific intereceptor which is also flawed.@shawkins thoughts? As far as I can see, these changes will enable the
HttpLoggingInterceptor
that can be activated based on the configured logging-level. If this one's OK, I'll send the interceptor implementation after merging.Type of change
test, version modification, documentation, etc.)
Checklist