-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Logging configuration for specific declarative RestClient using named "client" properties aka quarkus.rest-client."client".logging.* #45520
Conversation
🙈 The PR is closed and the preview is expired. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Realized just now, that my solution also can be used via QuarkusRestClientBuilder.newBuilder() |
RestClientsConfig.RestClientLoggingConfig logging = getConfiguration().hasProperty(QuarkusRestClientProperties.LOGGING) | ||
? (RestClientsConfig.RestClientLoggingConfig) getConfiguration() | ||
.getProperty(QuarkusRestClientProperties.LOGGING) | ||
: restClients.logging(); |
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.
I can't say I understand this. I read the comment in the discussion, but I still don't understand why it's necessary
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.
I'm just not sure it's correct to read a property and try to cast it to a specific type if the property is not really exists in map here. I thought that this way is more safe
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.
You are about has property or about ternary ?
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.
RestClientsConfig.RestClientLoggingConfig logging = (RestClientsConfig.RestClientLoggingConfig) getConfiguration() .getProperty(QuarkusRestClientProperties.LOGGING) : restClients.logging();
This is safe ?
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.
My point is that I don't understand why this specific was change was made in the first place. What didn't work with the previous code?
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.
My point is that I don't understand why this specific was change was made in the first place. What didn't work with the previous code?
Maybe i am wrong...
But as i understand previous code it reads only Global config for all clients (e. g . quarkus.rest-client.logging, not quarkus.rest-client."name".logging), not specific. All specific properties read from getConfiguration().getProperty... (which previously set via quarkusrestclientbuildercdidelegate) am i wrong ?
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.
Sorry, i am trying to tell what i mean in another way :(
Previous code reads this:
io.quarkus.restclient.config.RestClientsConfig.logging()
but i wanted to propagate this:
io.quarkus.restclient.config.RestClientsConfig.clients[client].logging()
so, logging would work in the first place only for a specific declarative client, not for all like it works now
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.
But as i understand previous code it reads only Global config for all clients (e. g . quarkus.rest-client.logging, not quarkus.rest-client."name".logging), not specific. All specific properties read from getConfiguration().getProperty... (which previously set via quarkusrestclientbuildercdidelegate) am i wrong ?
Correct, but the programmatic client doesn't have a name, so all it can do is read the global flag
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.
Looking at what other config things do, I guess this is fine. But I would like to not pass the config object as I mention in https://github.com/quarkusio/quarkus/pull/45520/files#r1912958630
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.
But as i understand previous code it reads only Global config for all clients (e. g . quarkus.rest-client.logging, not quarkus.rest-client."name".logging), not specific. All specific properties read from getConfiguration().getProperty... (which previously set via quarkusrestclientbuildercdidelegate) am i wrong ?
Correct, but the programmatic client doesn't have a name, so all it can do is read the global flag
Yeah! That's why I've done it via
- trying to read named configuration
- if no property has read from named config, trying to read global (for programmatic api support).
what am i missing ?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
private void configureLogging(QuarkusRestClientBuilder builder) { | ||
Optional<RestClientsConfig.RestClientLoggingConfig> logging = restClientConfig.logging(); | ||
if (logging.isPresent()) { | ||
builder.property(QuarkusRestClientProperties.LOGGING, logging.get()); | ||
} else if (configRoot.logging() != null) { | ||
builder.property(QuarkusRestClientProperties.LOGGING, configRoot.logging()); | ||
} | ||
} |
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.
We usually don't pass entire config objects like this, but only specific properties.
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.
We usually don't pass entire config objects like this, but only specific properties.
yeah, I saw that. But really there are no configs here, grouped by object, except multipart. So, I thought that my choice won't be wrong...
but if you said so, I need to rethink code / add separate constants for body-limit and logging-scope
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.
I would prefer we have separate constants for scope
and bodyLimit
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.
good, I will do it then
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.
🙏🏽
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.
@geoand last question for now
what do you think about these lines anyway:
else if (configRoot.logging() != null) {
builder.property(QuarkusRestClientProperties.LOGGING, configRoot.logging());
}
maybe i should not try read global config thing, while it anyway would be read in RestClientBuilderImpl:
: restClients.logging();
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.
Makes sense
f2b9547
to
1c22e49
Compare
...untime/src/main/java/org/jboss/resteasy/reactive/client/api/QuarkusRestClientProperties.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
restClientConfig.logging().ifPresent(logging -> { | ||
builder.property(QuarkusRestClientProperties.LOGGING_SCOPE, logging.scope() | ||
.map(LoggingScope::forName) | ||
.orElse(LoggingScope.NONE)); | ||
builder.property(QuarkusRestClientProperties.LOGGING_BODY_LIMIT, logging.bodyLimit()); | ||
}); |
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.
Can we get rid of the lambdas here please?
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.
of course.
I've just thought, that it is better then get().somproperty.
is lambda blocked over all project ?
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.
is lambda blocked over all project ?
Not strictly, it's just discouraged by some contributors (myself among them)
Status for workflow
|
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.
Thanks!
This comment has been minimized.
This comment has been minimized.
Status for workflow
|
Closes: #45519