Skip to content

Separate individual breadcrumb's data serialization#1250

Merged
st0012 merged 1 commit intomasterfrom
serialize-breadcrumbs-separately
Jan 30, 2021
Merged

Separate individual breadcrumb's data serialization#1250
st0012 merged 1 commit intomasterfrom
serialize-breadcrumbs-separately

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Jan 29, 2021

Breadcrumb can literally contain any type of data, and some of them can
cause problems when being serialized, like a hash or array that contains
circular references. Currently, this is causing the entire event to be
ditched because of the serialization error or SystemStackError, which is
bothering the users.

However, to stop bad data from being recorded is almost impossible, or at
least it'll be extremely expensive to check. So this commit takes a
different approach:

  1. we use JSON.parse(JSON.generate(breadcrumb_data)) in
    Breadcrumb#to_hash to make sure the generated Hash is
    serializable.
  2. if a breadcrumb's data is not serializable, the data will be
    thrown away but the breadcrumb will be preserved.
  3. whenever the serialization error happens, Sentry will log related
    messages to help future debugging.

Breadcrumb can literally contain any type of data, and some of them can
cause problems when being serialized, like a hash or array that contains
circular references. Currently, this is causing the entire event to be
ditched because of the serialization error or SystemStackError, which is
bothering the users.

However, to stop bad data from being recorded is almost impossible, or at
least it'll be extremely expensive to check. So this commit takes a
different approach:

1. we use `JSON.parse(JSON.generate(breadcrumb_data))` in
   `Breadcrumb#to_hash` to make sure the generated Hash is
   serializable.
2. if a breadcrumb's data is not serializable, the data will be
   thrown away but the breadcrumb will be preserved.
3. whenever the serialization error happens, Sentry will log related
   messages to help future debugging.
@st0012 st0012 added this to the sentry-ruby-4.1.6 milestone Jan 29, 2021
@st0012 st0012 self-assigned this Jan 29, 2021
@codecov-io
Copy link
Copy Markdown

codecov-io commented Jan 29, 2021

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.54%. Comparing base (e9a2f62) to head (53451bb).
⚠️ Report is 1132 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1250      +/-   ##
==========================================
+ Coverage   97.88%   98.54%   +0.66%     
==========================================
  Files         193      100      -93     
  Lines        8324     4550    -3774     
==========================================
- Hits         8148     4484    -3664     
+ Misses        176       66     -110     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@st0012 st0012 merged commit 8fbb8d7 into master Jan 30, 2021
@st0012 st0012 deleted the serialize-breadcrumbs-separately branch January 30, 2021 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants