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

More useful toString on UpdateSettingsTask #93514

Merged

Conversation

DaveCTurner
Copy link
Contributor

Today UpdateSettingsTask#toString is just the default which is not helpful when it appears in logs. This commit makes it include the affected indices and settings.

Today `UpdateSettingsTask#toString` is just the default which is not
helpful when it appears in logs. This commit makes it include the
affected indices and settings.
@DaveCTurner DaveCTurner added >non-issue :Data Management/Indices APIs APIs to create and manage indices and templates v8.7.0 labels Feb 6, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Feb 6, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@DaveCTurner
Copy link
Contributor Author

For the record the relevant toString() call is the one here:

default String describeTasks(List<T> tasks) {
final StringBuilder output = new StringBuilder();
Strings.collectionToDelimitedStringWithLimit(
(Iterable<String>) () -> tasks.stream().map(Object::toString).filter(s -> s.isEmpty() == false).iterator(),
", ",
"",
"",
1024,
output
);
return output.toString();
}

We only call this if we need the full string description of the tasks for some reason (typically trace logging), otherwise this code is not called.


@Override
public String toString() {
return Arrays.toString(indices()) + settings;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it mention anywhere that this is UpdateSettingsClusterStateUpdateRequest?
I wonder if it might not be immediately obvious what produced the string in case we have many strings from distinct cluster state update tasks.

Copy link
Contributor Author

@DaveCTurner DaveCTurner Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also include the source of the tasks (which is entry.getKey() here:

return tasks.isEmpty() ? entry.getKey() : entry.getKey() + "[" + tasks + "]";

For the update-settings tasks this includes the string update-settings so I think there is no chance of confusion here.

Copy link
Contributor

@idegtiarenko idegtiarenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a non-blocking suggestion, otherwise LGTM

@DaveCTurner DaveCTurner merged commit b199470 into elastic:main Feb 6, 2023
@DaveCTurner DaveCTurner deleted the 2023-02-06-UpdateSettingsTask-toString branch February 6, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates >non-issue Team:Data Management Meta label for data/management team v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants