Skip to content

[Idea] Avoid silent failures or make more noise when maximum JSON message size reached #268

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

Closed
robert-resemble opened this issue Mar 11, 2024 · 0 comments

Comments

@robert-resemble
Copy link

robert-resemble commented Mar 11, 2024

Hi there, I recently encountered a rather nasty error which has had some costly effects in terms of lost data. Essentially, our team discovered we had a gradual data drift in our downstream data science / product dashboards causal to lost messages sent to mixpanel.

After a bit of investigation, I discovered that there is a maximum JSON serialization limit for JSON generation. One of the challenges for us was that we didn't realize the gem caught this error and piped out to logs. Our log pipelines are quite busy so its hard to catch minor errors like this.

I wonder if it might make sense to simply raise an error saying "Limit of message reached" when you try to track an event with a message size > 32k, instead of logging and failing silently.

MAX_BYTES = 32768 # 32Kb

message_json = message.to_json
rescue StandardError => e
raise JSONGenerationError, "Serialization error: #{e}"
end
message_json_size = message_json.bytesize
if message_too_big?(message_json_size)
logger.error('a message exceeded the maximum allowed size')

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

No branches or pull requests

2 participants