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

File/attachment uploads #2357

Merged
merged 8 commits into from
Aug 8, 2024
Merged

Conversation

solnic
Copy link
Collaborator

@solnic solnic commented Jul 29, 2024

This adds support for attaching files to the scope like this:

# Using path option
Sentry.add_attachment(path: "/your/attachment.txt")

# Using filename and bytes
Sentry.add_attachment(filename: "attachment.txt", bytes: File.read("/your/attachment.txt"))
Screenshot 2024-08-06 at 12 54 36

TODO

  • Add Sentry.add_attachment(**opts)
  • Extend Transport and Envelope with support for sending attachments
  • Add support for :path option
  • Add support for figuring out content_type automatically based on filename
  • Ensure that either bytes or file content as a string are supported and that multi-line content is working

Closes #1548

@solnic solnic linked an issue Jul 29, 2024 that may be closed by this pull request
@solnic solnic added the wip label Jul 29, 2024
Copy link

codecov bot commented Jul 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.70%. Comparing base (e4571d9) to head (d3cb111).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2357      +/-   ##
==========================================
+ Coverage   98.67%   98.70%   +0.03%     
==========================================
  Files         208      209       +1     
  Lines       13748    13837      +89     
==========================================
+ Hits        13566    13658      +92     
+ Misses        182      179       -3     
Components Coverage Δ
sentry-ruby 99.06% <100.00%> (+0.02%) ⬆️
sentry-rails 97.41% <ø> (ø)
sentry-sidekiq 97.01% <ø> (ø)
sentry-resque 97.11% <ø> (+0.32%) ⬆️
sentry-delayed_job 98.92% <ø> (ø)
sentry-opentelemetry 100.00% <ø> (ø)
Files Coverage Δ
sentry-ruby/lib/sentry-ruby.rb 96.71% <100.00%> (+0.04%) ⬆️
sentry-ruby/lib/sentry/attachment.rb 100.00% <100.00%> (ø)
sentry-ruby/lib/sentry/event.rb 98.57% <100.00%> (+0.04%) ⬆️
sentry-ruby/lib/sentry/scope.rb 100.00% <100.00%> (ø)
sentry-ruby/lib/sentry/transport.rb 99.07% <100.00%> (+0.02%) ⬆️
sentry-ruby/spec/sentry/scope_spec.rb 100.00% <100.00%> (ø)
sentry-ruby/spec/sentry/transport_spec.rb 100.00% <100.00%> (ø)
sentry-ruby/spec/sentry_spec.rb 99.85% <100.00%> (+<0.01%) ⬆️

... and 3 files with indirect coverage changes

@solnic solnic force-pushed the solnic/1548-fileattachment-uploads branch 2 times, most recently from 0b902f4 to a3f2ba8 Compare July 31, 2024 10:29
sentry-ruby/sentry-ruby.gemspec Outdated Show resolved Hide resolved
@solnic solnic force-pushed the solnic/1548-fileattachment-uploads branch from a3f2ba8 to e9acf35 Compare August 5, 2024 10:06
@solnic solnic requested a review from sl0thentr0py August 5, 2024 10:43
@solnic solnic force-pushed the solnic/1548-fileattachment-uploads branch 2 times, most recently from 2985a36 to de87c9a Compare August 6, 2024 09:03
@solnic solnic force-pushed the solnic/1548-fileattachment-uploads branch from de87c9a to 03b17f9 Compare August 6, 2024 09:34
@solnic solnic removed the wip label Aug 6, 2024
@solnic solnic marked this pull request as ready for review August 6, 2024 10:28
@solnic solnic force-pushed the solnic/1548-fileattachment-uploads branch from 03b17f9 to 6f67d4e Compare August 6, 2024 10:47
Copy link
Member

@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.

couple of comments

@@ -5,6 +5,7 @@
- Support for tracing Faraday requests ([#2345](https://github.com/getsentry/sentry-ruby/pull/2345))
- Closes [#1795](https://github.com/getsentry/sentry-ruby/issues/1795)
- Please note that the Faraday instrumentation has some limitations in case of async requests: https://github.com/lostisland/faraday/issues/1381
- Support for attachments ([#2357](https://github.com/getsentry/sentry-ruby/pull/2357))
Copy link
Member

Choose a reason for hiding this comment

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

for new features, we add a small snippet below the changelog entry that shows users how to use the new feature. So here,

Sentry.add_attachment(path: '/foo/bar.txt')
Sentry.add_attachment(filename: 'payload.json', bytes: '{"value": 42}'))

sentry-ruby/lib/sentry/attachment.rb Outdated Show resolved Hide resolved
@solnic solnic requested a review from sl0thentr0py August 8, 2024 12:12
@sl0thentr0py sl0thentr0py merged commit 837577a into master Aug 8, 2024
7 of 28 checks passed
@sl0thentr0py sl0thentr0py deleted the solnic/1548-fileattachment-uploads branch August 8, 2024 12:51
Copy link

github-actions bot commented Aug 8, 2024

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- File/attachment uploads ([#2357](https://github.com/getsentry/sentry-ruby/pull/2357))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by 🚫 dangerJS against 27b078d

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.

File/attachment uploads
2 participants