Skip to content
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

Improve logging of Spring Cloud Config extension #38457

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public Iterable<ConfigSource> getConfigSources(final ConfigSourceContext context
VertxSpringCloudConfigGateway client = new VertxSpringCloudConfigGateway(config);
try {
List<Response> responses = new ArrayList<>();
for (String profile : determineProfiles(context, config)) {
List<String> profiles = determineProfiles(context, config);
log.debug("The following profiles will be used to look up properties: " + profiles);
for (String profile : profiles) {
Response response;
if (connectionTimeoutIsGreaterThanZero || readTimeoutIsGreaterThanZero) {
response = client.exchange(applicationName.getValue(), profile).await()
Expand All @@ -64,9 +66,13 @@ public Iterable<ConfigSource> getConfigSources(final ConfigSourceContext context

if (response.getProfiles().contains(profile)) {
responses.add(response);
} else {
log.debug("Response did not contain profile " + profile);
}
}

log.debug("Obtained " + responses.size() + " from the config server");

int ordinal = 450;
// Profiles are looked from the highest ordinal to lowest, so we reverse the collection to build the source list
Collections.reverse(responses);
Expand All @@ -76,7 +82,14 @@ public Iterable<ConfigSource> getConfigSources(final ConfigSourceContext context
Collections.reverse(propertySources);

for (PropertySource propertySource : propertySources) {
sources.add(SpringCloudPropertySource.from(propertySource, response.getProfiles(), ordinal++));
int ord = ordinal++;
if (log.isDebugEnabled()) {
log.debug("Adding PropertySource named '" + propertySource.getName() + "', with and ordinal of '" + ord
+ "' that contains the following keys: "
+ String.join(",", propertySource.getSource().keySet()));
}

sources.add(SpringCloudPropertySource.from(propertySource, response.getProfiles(), ord));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public Uni<Response> exchange(String applicationName, String profile) {
}
log.debug("Attempting to read configuration from '" + finalURI + "'.");
return request.send().map(r -> {
log.debug("Received HTTP response code '" + r.statusCode() + "'");
if (r.statusCode() != 200) {
throw new RuntimeException("Got unexpected HTTP response code " + r.statusCode()
+ " from " + finalURI);
Expand All @@ -214,6 +215,7 @@ public Uni<Response> exchange(String applicationName, String profile) {
throw new RuntimeException("Got empty HTTP response body " + finalURI);
}
try {
log.debug("Attempting to deserialize response");
return OBJECT_MAPPER.readValue(bodyAsString, Response.class);
} catch (JsonProcessingException e) {
throw new RuntimeException("Got unexpected error " + e.getOriginalMessage());
Expand Down
Loading