Skip to content

[CT-2264] Don't raise exception during event serialization failure, just log warning #7113

@jtcohen6

Description

@jtcohen6

Instead of raising as an Exception that stops the whole run, let's instead fire a different warn-level event to call out the event serialization failure. Ideally, this would include enough information about the event's contents (serialized as a string?) that would be helpful in debugging, but let's make extra sure that doesn't silently/loudly fail either.

In main branch:

try:
msg_dict = msg.to_dict(casing=betterproto.Casing.SNAKE, include_default_values=True) # type: ignore
except AttributeError as exc:
event_type = type(msg).__name__
raise Exception(f"type {event_type} is not serializable. {str(exc)}")

In 1.3.latest (should be similar in 1.2.latest and 1.1.latest):

try:
log_line = e.to_dict()
except AttributeError as exc:
event_type = type(e).__name__
raise Exception( # TODO this may hang async threads
f"type {event_type} is not serializable. {str(exc)}"
)

Metadata

Metadata

Assignees

Labels

loggingtech_debtBehind-the-scenes changes, with little direct impact on end-user functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions