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

feat: clarify key or value in (de)serialization processing log messages #6109

Merged
merged 5 commits into from
Sep 8, 2020

Conversation

vcrfxia
Copy link
Contributor

@vcrfxia vcrfxia commented Aug 27, 2020

Description

Fixes #5627

Currently, there's nothing in the processing log message for (de)serialization errors to indicate whether it was the record key or value that failed to serialize/deserialize. This PR adds a new field to the relevant processing log message schemas called "component" with value "key" or "value" to indicate so.

Not in love with the name "component" but couldn't think of anything better. Suggestions appreciated!

Also fixes a typo in the Kafka deserializer error message that indicated the wrong format (delimited).

Testing done

Unit + manual.

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@vcrfxia vcrfxia requested review from JimGalasyn and a team as code owners August 27, 2020 15:16
@@ -121,6 +121,11 @@ message.deserializationError (STRUCT)
: The contents of a message with type 0 (DESERIALIZATION_ERROR).
Logged when a deserializer fails to deserialize an {{ site.ak }} record.

message.deserializationError.component (STRING)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a huge fan of the name "component" but couldn't think of anything better. Hopefully someone else has a better suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

I poked around a bit and didn't see consensus on a good term, but I did see a few sources using the very technical term "part", like "key-part" and "value-part".

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't mind component or part, or how about target?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, updated to "target".

Copy link
Member

@JimGalasyn JimGalasyn left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@big-andy-coates big-andy-coates left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @vcrfxia

@@ -121,6 +121,11 @@ message.deserializationError (STRUCT)
: The contents of a message with type 0 (DESERIALIZATION_ERROR).
Logged when a deserializer fails to deserialize an {{ site.ak }} record.

message.deserializationError.component (STRING)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't mind component or part, or how about target?

}

@Override
public int hashCode() {
return Objects.hash(exception, record, topic);
return Objects.hash(exception, record, topic, isKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a unit test testing this. Can you add one please?

}

@Override
public int hashCode() {
return Objects.hash(exception, record, topic);
return Objects.hash(exception, record, topic, isKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a unit test testing this. Can you add one please?


static List<String> getCause(final Throwable exception) {
final List<String> cause = ErrorMessageUtil.getErrorMessages(exception);
cause.remove(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is a cut & paste, but I've seen this remove(0) remove the actual cause of the error, e.g. I've seen cases where exception is a simple NullPointerException and the remove(0) has resulted in an empty cause list.

Personally, I'd remove the remove and inline this method.

Which would only leave getRecordComponent, which I'd also be tempted to remove, and just add appropriate "key" and "value" constants to ProcessingLogMessageSchema instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first error message (the one being removed by this line) is already captured in the errorMessage field, which is why it's purposefully left out of the cause field. It sounds like you're advocating for duplication of the initial error message, so that the cause field is complete?

@@ -60,6 +61,7 @@
@Before
public void setUp() {
deserializer = new LoggingDeserializer<>(delegate, processingLogger);
deserializer.configure(Collections.emptyMap(), false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably worth adding a test that called configure with isKey=true, and ensure logged error has isKey=true.

Same for LoggingSerializerTest.

@vcrfxia vcrfxia merged commit 7a16b91 into confluentinc:master Sep 8, 2020
@vcrfxia vcrfxia deleted the processing-log-deser-key branch September 8, 2020 02:14
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.

Processing log: deserialization errors for keys
3 participants