-
Notifications
You must be signed in to change notification settings - Fork 974
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
Callbacks for Connection initialization #555
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tippl I apologize if I have said was misleading but the idea was to provide hooks for performance metrics without exposing the whole thing in the public APIs.
- Please add those callback methods as protected empty methods to the
DefaultHttpClientConnectionOperator
. One would need to subclassDefaultHttpClientConnectionOperator
and override relevant methods in order to add custom logic - Symmetric changes need to be made
DefaultHttpClientConnectionOperator
. We must keep the classic and the async client implementation consistent.
@ok2c
If you're okay with these, I'll work on implementing the changes. |
@tippl Do you mean
Sure.
Sure thing. Makes sense. |
As it stands now, ignoring the deprecated constructors of So there is no way to actually create a In the mail thread, you suggested making the protected constructor public, but I feel rather adding So if you specify a This is what i meant. |
One can subclass |
Is there a reason for not being able to add the To me it feels counterproductive. Past several releases of this library have been focused on making the Builder be the main/only way to create a Especially since the only reason for extending in this case would be to access a protected constructor. If this is a feature the library provides, an user shouldn't use workarounds to use it at all. |
@tippl The are two reasons:
That is exactly the thing. This feature may be very important for your application but, dare I say, for majority of users it is completely irrelevant. |
I've come across the idea for these metrics here micrometer-metrics/micrometer#1617, so I cannot say i'm the only one who wants these metrics, but the pool of people is certainly small. Which is why I wanted to make it fairly simple to implement into micrometer, so that I wouldn't have to make these ugly hacks myself and more people could use them. Your point about conflicting attributes is valid though. I'll update the PR when i have time. |
12e53da
to
6905e83
Compare
@ok2c Sorry for the delay. I've tried to avoid the need of having to extend the I've also modified the bulilders to allow extending, this way even if you want to use the callbacks, you don't have to fully manually configure the |
@tippl Everything looks good to me except for builders. Your change exposes every single internal implementation detail to the public APIs making it almost impossible to modify the classes without breaking the APIs. If you are absolutely sure that you must make those builders extendable, please provide an internal protected method instead. See internal protected methods in |
Changing to protected instance variables are a very bad idea IMO: we are handcuffing ourselves to names, types and details that break encapsulation. A subclass should use methods to access what it needs. This gives us the most flexibility to change code and implementation in the future. |
6905e83
to
333757f
Compare
Hopefully this is how you meant it. :) Yeah, exposing the private variables wasn't ideal, but all of this is kind of not ideal since it's trying to expose callbacks for api users without exposing the callbacks in the api and there's not much room to jam it in and not make creating the objects an absolute pain that would make no one want to use the callbacks. :( I still feel that exposing a callback interface in the builder as i did the first time is the least intrusive, but i'll defer to the maintainers. |
.../main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java
Outdated
Show resolved
Hide resolved
333757f
to
396c5e0
Compare
396c5e0
to
fe51e6a
Compare
One more edit, making the Builder constructor not protected means you cannot extend it. Made an oversight when removing the protected there. |
As discussed on the mailing list, implements a callback for Connection initialization steps.
Useful for collection of metrics on how long each step takes for network troubleshooting.