getsentry / getsentry/sentry-ruby

Opaque with_scope behaviour with exceptions in block

Đang mở
#1,855 9 bình luận 2 reaction 1 người được giao Được @sl0thentr0py nhận Xem trên GitHub
Discussion Errors Improvement Question Ruby sentry-ruby
Ngôn ngữ chính
Ruby
Star
987
Fork
541
Merge trung bình
17 giờ 40 phút
Pull request đã merge (30 ngày)
19

Mô tả

Creating this issue for further discussion.

If you do the following, the exception will be captured but the tag won't be used (because that scope is thrown away in [an ensure](https://github.com/getsentry/sentry-ruby/blob/332315907185e6ffe05aa64dc751cdd8ab9f5448/sentry-ruby/lib/sentry/hub.rb#L60-L61)).
```ruby
Sentry.with_scope do |scope|
scope.set_tags(my_tag: "my value")
1 / 0
end
```

If you do the following, the exception will be captured _and_ the tag will be visible.
```ruby
Sentry.with_scope do |scope|
scope.set_tags(my_tag: "my value")

begin
1 / 0
rescue => e
Sentry.capture_exception(e)
end
end
```

_Originally posted by @sl0thentr0py in https://github.com/getsentry/sentry-docs/pull/5328#issuecomment-1194148134_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.