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

ENH: Plugin errors consolidator #4863

Conversation

chenqi0805
Copy link
Collaborator

Description

This is an enhancement on consolidated plugin error messages to make sure error messages are filtered.

Issues Resolved

Resolves #4854

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: George Chen <qchea@amazon.com>
Signed-off-by: George Chen <qchea@amazon.com>
Comment on lines +66 to +70
final List<PluginError> extensionPluginErrors = pluginErrorCollector.getPluginErrors()
.stream().filter(pluginError -> PipelinesDataFlowModel.EXTENSION_PLUGIN_TYPE
.equals(pluginError.getComponentType()))
.collect(Collectors.toList());
if (!extensionPluginErrors.isEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we have one of the unit tests cover this filtering? to verify that if there are pluginErrors with type other than "extension", they will be filtered out.

import java.util.stream.IntStream;

@Named
public class PluginErrorsConsolidator {
Copy link
Member

Choose a reason for hiding this comment

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

I think rather than make this a consolidator that creates a string, a more flexible approach would be to make a PluginErrorsHandler. Let it decide how to handle multiple errors. Maybe it handles it by creating a structured object. Maybe it handles it by logging. Maybe by stdout.

public interface PluginErrorsHandler {
  public void handleErrors(final Collection<PluginError> pluginErrors);
}

And then we can have a default which logs:

@Named
public class LoggingPluginErrorsHandler implements PluginErrorsHandler {
  public void handleErrors(final Collection<PluginError> pluginErrors) {
    // build string
    // log to Slf4j
  }
}

Signed-off-by: George Chen <qchea@amazon.com>
dlvenable
dlvenable previously approved these changes Aug 27, 2024
Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

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

Nice, thanks for making this improvement!

oeyh
oeyh previously approved these changes Aug 27, 2024
Copy link
Collaborator

@oeyh oeyh left a comment

Choose a reason for hiding this comment

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

There's a build failure with checkStyle.

Signed-off-by: George Chen <qchea@amazon.com>
@chenqi0805 chenqi0805 dismissed stale reviews from oeyh and dlvenable via 89d15ed August 27, 2024 15:41
dlvenable
dlvenable previously approved these changes Aug 27, 2024
oeyh
oeyh previously approved these changes Aug 27, 2024
Copy link
Collaborator

@oeyh oeyh left a comment

Choose a reason for hiding this comment

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

Thanks! I'm good with it once build succeeds.

Signed-off-by: George Chen <qchea@amazon.com>
@chenqi0805 chenqi0805 dismissed stale reviews from oeyh and dlvenable via d4fdbb0 August 27, 2024 15:50
@chenqi0805 chenqi0805 merged commit 9c14d11 into opensearch-project:main Aug 27, 2024
44 of 47 checks passed
@chenqi0805 chenqi0805 deleted the enh/4854-plugin-errors-consolidator branch August 27, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using Custom class to handle collection of error messages from PluginErrorCollector
3 participants