-
Notifications
You must be signed in to change notification settings - Fork 202
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
Add handle failed events option to parse json processors #4844
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.model.event; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
class HandleFailedEventsOptionTest { | ||
@ParameterizedTest | ||
@EnumSource(HandleFailedEventsOption.class) | ||
void fromOptionValue(final HandleFailedEventsOption option) { | ||
assertThat(HandleFailedEventsOption.fromOptionValue(option.name()), CoreMatchers.is(option)); | ||
|
||
if (option == HandleFailedEventsOption.SKIP || option == HandleFailedEventsOption.SKIP_SILENTLY) { | ||
assertThat(option.shouldDropEvent(), equalTo(false)); | ||
} else { | ||
assertThat(option.shouldDropEvent(), equalTo(true)); | ||
} | ||
|
||
if (option == HandleFailedEventsOption.SKIP_SILENTLY || option == HandleFailedEventsOption.DROP_SILENTLY) { | ||
assertThat(option.shouldLog(), equalTo(false)); | ||
} else { | ||
assertThat(option.shouldLog(), equalTo(true)); | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,11 @@ | |
package org.opensearch.dataprepper.plugins.processor.parse.ion; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyDescription; | ||
import jakarta.validation.constraints.AssertTrue; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import org.opensearch.dataprepper.model.event.HandleFailedEventsOption; | ||
import org.opensearch.dataprepper.plugins.processor.parse.CommonParseConfig; | ||
|
||
import java.util.List; | ||
|
@@ -38,6 +41,14 @@ public class ParseIonProcessorConfig implements CommonParseConfig { | |
@JsonProperty | ||
private boolean deleteSource = false; | ||
|
||
@JsonProperty("handle_failed_events") | ||
@JsonPropertyDescription("Determines how to handle events with ION processing errors. Options include 'skip', " + | ||
"which will log the error and send the Event downstream to the next processor, and 'skip_silently', " + | ||
"which will send the Event downstream to the next processor without logging the error. " + | ||
"Default is 'skip'.") | ||
@NotNull | ||
private HandleFailedEventsOption handleFailedEventsOption = HandleFailedEventsOption.SKIP; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means, default behavior is not changed, right? ie, the failures are logged and skipped. This also, means customers will see this issue, unless they explicitly change this. Is this what is agreed upon? Should we set it to SKIP_SILENTLY in OSI? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that's right default is to log and skip still. OSI default decision will be made separately |
||
|
||
@Override | ||
public String getSource() { | ||
return source; | ||
|
@@ -78,4 +89,22 @@ boolean isValidDestination() { | |
public boolean isDeleteSourceRequested() { | ||
return deleteSource; | ||
} | ||
|
||
@Override | ||
public HandleFailedEventsOption getHandleFailedEventsOption() { | ||
return handleFailedEventsOption; | ||
} | ||
|
||
@AssertTrue(message = "handled_failed_events must be set to 'skip' or 'skip_silently'.") | ||
boolean isHandleFailedEventsOptionValid() { | ||
if (handleFailedEventsOption == null) { | ||
return true; | ||
} | ||
|
||
if (handleFailedEventsOption.shouldDropEvent()) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
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 you replace the existing option in
drop
processor with this? Thedrop
anddrop_silently
options from that processor seems a decent option to provide elsewhere.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 originally wanted to do this, but if we don't support those two options in the parse processors, then it's a bit weird to have there isn't it? Although I could just add a validation that does not allow drop or drop_silently for these processors
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.
Yes, I think a validation would be appropriate.