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: Add client reports #1604

Merged
merged 26 commits into from
Nov 11, 2021
Merged

feat: Add client reports #1604

merged 26 commits into from
Nov 11, 2021

Conversation

sl0thentr0py
Copy link
Member

@sl0thentr0py sl0thentr0py commented Nov 5, 2021

This PR adds support for Client Reports.

  • new config send_client_reports, true by default
  • record lost events in Transport
  • attach them to an existing envelope while sending, max 1 per 30 seconds
    • PS: this differs from python which needs to do extra scheduling when it sends events via the store endpoint

Some notes:

  • I used minitest before, so if I did something incorrect while writing the specs, please let me know :)
  • I still want to test this a bit more manually since it's my first PR, so making draft for now

@sl0thentr0py sl0thentr0py requested review from st0012, a team, lobsterkatie and iker-barriocanal and removed request for a team November 5, 2021 14:45
Copy link
Collaborator

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Generally looks good. Just some suggestions on styling and testing 👍

sentry-ruby/lib/sentry/transport.rb Outdated Show resolved Hide resolved
sentry-ruby/spec/sentry/client/event_sending_spec.rb Outdated Show resolved Hide resolved
sentry-ruby/spec/sentry/client/event_sending_spec.rb Outdated Show resolved Hide resolved
sentry-ruby/spec/sentry/client/event_sending_spec.rb Outdated Show resolved Hide resolved
sentry-ruby/spec/sentry/client/event_sending_spec.rb Outdated Show resolved Hide resolved
sentry-ruby/spec/sentry/client/event_sending_spec.rb Outdated Show resolved Hide resolved
sentry-ruby/spec/sentry/transaction_spec.rb Outdated Show resolved Hide resolved
sentry-ruby/spec/sentry/transport_spec.rb Outdated Show resolved Hide resolved
sentry-ruby/lib/sentry/transport.rb Show resolved Hide resolved
sentry-ruby/lib/sentry/transport.rb Show resolved Hide resolved
Copy link

@iker-barriocanal iker-barriocanal left a comment

Choose a reason for hiding this comment

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

Didn't review the PR in-depth but overall looks good to me. I only have one question: we can read the following in the docs

[...] to periodically flush them out as separate envelope item or attach it to an already scheduled envelope.

If no envelope is sent for a long time (say, 5 minutes), does the SDK wait for the next envelope to add the client reports, or reports them before that (in an envelope with potentially only client reports)?

@st0012
Copy link
Collaborator

st0012 commented Nov 8, 2021

@sl0thentr0py do you think this can go out this week?

@sl0thentr0py
Copy link
Member Author

hmm I can finish making the changes and testing by tomorrow I think, so unless I find some problems, I'd say yes?

@st0012
Copy link
Collaborator

st0012 commented Nov 8, 2021

@sl0thentr0py awesome. I'm thinking about releasing version 4.8.0 with this feature this week (align with RubyConf).

@sl0thentr0py
Copy link
Member Author

@iker-barriocanal
short answer: no it doesn't send it's own envelope currently, it is always attached to an existing envelope.


long answer:
If the actual requirement is to always ensure 1 client report per minute, that's not so trivial because you would need some coordinating parent process that ensures this scheduling logic. AFAICT, none of the sdks implement this in that sense.

What the other 2 sdks do:

However, this 60 second scheduling is itself done only in capture_event and capture_envelope which implies that you eventually need some event/transaction to be fired to schedule this 'client report only' envelope.

Another difference: python has both capture_event which goes to the store endpoint and capture_envelope which goes to the envelope endpoint, hence the need for the separate envelope scheduling. Ruby sends everything to envelope anyway so I'm not sure we need to schedule the other one at all.

For now, considering my current understanding of what we need client reports for, I think this implementation for ruby is fine. Let me know if you have questions.

@iker-barriocanal
Copy link

@sl0thentr0py sure, I was just asking the question, LGTM as it is. The only thing I'd add to this conversation is to explicitly mention it somewhere, and IMO the short answer in the PR description should do it (or be more explicit on the third point).

sentry-ruby/lib/sentry/transport.rb Outdated Show resolved Hide resolved
sentry-ruby/lib/sentry/transport.rb Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2021

Codecov Report

Merging #1604 (d9ec041) into master (1bf154e) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1604      +/-   ##
==========================================
+ Coverage   98.43%   98.51%   +0.08%     
==========================================
  Files         130      130              
  Lines        7223     7285      +62     
==========================================
+ Hits         7110     7177      +67     
+ Misses        113      108       -5     
Impacted Files Coverage Δ
sentry-ruby/lib/sentry/client.rb 100.00% <100.00%> (+2.53%) ⬆️
sentry-ruby/lib/sentry/configuration.rb 98.38% <100.00%> (+0.01%) ⬆️
sentry-ruby/lib/sentry/transaction.rb 100.00% <100.00%> (ø)
sentry-ruby/lib/sentry/transport.rb 98.79% <100.00%> (+0.61%) ⬆️
...ntry-ruby/spec/sentry/client/event_sending_spec.rb 99.60% <100.00%> (+0.03%) ⬆️
sentry-ruby/spec/sentry/transaction_spec.rb 100.00% <100.00%> (ø)
sentry-ruby/spec/sentry/transport_spec.rb 100.00% <100.00%> (ø)
sentry-sidekiq/lib/sentry-sidekiq.rb 73.91% <0.00%> (-17.40%) ⬇️
sentry-rails/app/jobs/sentry/send_event_job.rb 60.00% <0.00%> (-13.34%) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1bf154e...d9ec041. Read the comment docs.

@sl0thentr0py
Copy link
Member Author

Tested the sample rate case end-to-end, looks good to me
Screenshot 2021-11-09 at 13 22 22

@@ -44,6 +44,12 @@
config.before(:each, rack: true) do
skip("skip rack related tests") unless defined?(Rack)
end

RSpec::Matchers.define :have_recorded_lost_event do |reason, type|
Copy link
Member Author

Choose a reason for hiding this comment

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

@st0012 not an rspec pro so not sure if this is the right way to do this? let me know :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it looks good and I've also tested it locally 👍

Copy link
Member Author

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

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

@st0012 changed the specs and made some minor changes based on various comments above, can you take it for another spin?

@sl0thentr0py sl0thentr0py marked this pull request as ready for review November 10, 2021 12:02
Copy link
Collaborator

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Thanks for the amazing feature 👍

@st0012 st0012 merged commit d654a60 into master Nov 11, 2021
@st0012 st0012 deleted the client-reports branch November 11, 2021 10:58
@sl0thentr0py
Copy link
Member Author

@st0012 thank you for helping me with my first PR!

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.

5 participants