sentry-ruby-core 4.1.6 → 4.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.craft.yml +3 -3
- data/CHANGELOG.md +171 -1
- data/Gemfile +6 -3
- data/README.md +39 -49
- data/lib/sentry-ruby.rb +30 -9
- data/lib/sentry/background_worker.rb +8 -4
- data/lib/sentry/breadcrumb.rb +7 -2
- data/lib/sentry/breadcrumb/sentry_logger.rb +2 -1
- data/lib/sentry/breadcrumb_buffer.rb +3 -2
- data/lib/sentry/client.rb +62 -28
- data/lib/sentry/configuration.rb +80 -17
- data/lib/sentry/event.rb +33 -45
- data/lib/sentry/exceptions.rb +7 -0
- data/lib/sentry/hub.rb +24 -4
- data/lib/sentry/interface.rb +1 -0
- data/lib/sentry/interfaces/exception.rb +19 -1
- data/lib/sentry/interfaces/request.rb +10 -10
- data/lib/sentry/interfaces/single_exception.rb +16 -4
- data/lib/sentry/interfaces/stacktrace.rb +9 -26
- data/lib/sentry/interfaces/stacktrace_builder.rb +50 -0
- data/lib/sentry/interfaces/threads.rb +32 -0
- data/lib/sentry/net/http.rb +126 -0
- data/lib/sentry/rack/capture_exceptions.rb +18 -14
- data/lib/sentry/rake.rb +1 -1
- data/lib/sentry/scope.rb +12 -6
- data/lib/sentry/span.rb +21 -4
- data/lib/sentry/transaction.rb +55 -43
- data/lib/sentry/transaction_event.rb +3 -1
- data/lib/sentry/transport.rb +58 -27
- data/lib/sentry/transport/configuration.rb +3 -1
- data/lib/sentry/transport/http_transport.rb +92 -6
- data/lib/sentry/utils/logging_helper.rb +24 -0
- data/lib/sentry/utils/real_ip.rb +13 -7
- data/lib/sentry/version.rb +1 -1
- data/sentry-ruby-core.gemspec +1 -1
- data/sentry-ruby.gemspec +1 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b3c9b486a84c3c47a161b6aa840c3b1e2e43946acd77e7caebe63e7c2c2fe58
|
4
|
+
data.tar.gz: db161d2d4379a8d0a9340e1c7edb113955221b04792d60d21e96d7624b3c76c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc596e7d1a951cef5298a18800728490976c2ec5bf3516e353364c6cf6f14af607e3faf2fd36949792a5ff38c534ea42b7384f88976428d355c2a9df55d41117
|
7
|
+
data.tar.gz: 138f3eb99eccbcc2286c0e82eeab7ccc2a44f45e112c5ef4e68513f73dc441c47558a77e8efd40838e39465c2181fe74dffc0a9280e04d2a6cbaf7d0260eabd5
|
data/.craft.yml
CHANGED
@@ -13,9 +13,6 @@ targets:
|
|
13
13
|
# we always need to make sure sentry-ruby-core is present when pushing to any target
|
14
14
|
- name: gem
|
15
15
|
onlyIfPresent: /^sentry-ruby-core-\d.*\.gem$/
|
16
|
-
- name: github
|
17
|
-
onlyIfPresent: /^sentry-ruby-core-\d.*\.gem$/
|
18
|
-
tagPrefix: sentry-ruby-v
|
19
16
|
- name: registry
|
20
17
|
onlyIfPresent: /^sentry-ruby-core-\d.*\.gem$/
|
21
18
|
type: sdk
|
@@ -26,3 +23,6 @@ targets:
|
|
26
23
|
type: sdk
|
27
24
|
config:
|
28
25
|
canonical: 'gem:sentry-ruby-core'
|
26
|
+
- name: github
|
27
|
+
onlyIfPresent: /^sentry-ruby-core-\d.*\.gem$/
|
28
|
+
tagPrefix: sentry-ruby-v
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,176 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
Individual gem's changelog has been deprecated. Please check the [project changelog](https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md).
|
4
|
+
|
5
|
+
## 4.4.2
|
6
|
+
|
7
|
+
- Fix NoMethodError when SDK's dsn is nil [#1433](https://github.com/getsentry/sentry-ruby/pull/1433)
|
8
|
+
- fix: Update protocol version to 7 [#1434](https://github.com/getsentry/sentry-ruby/pull/1434)
|
9
|
+
- Fixes [#867](https://github.com/getsentry/sentry-ruby/issues/867)
|
10
|
+
|
11
|
+
## 4.4.1
|
12
|
+
|
13
|
+
- Apply patches when initializing the SDK [#1432](https://github.com/getsentry/sentry-ruby/pull/1432)
|
14
|
+
|
15
|
+
## 4.4.0
|
16
|
+
|
17
|
+
### Features
|
18
|
+
|
19
|
+
#### Support category-based rate limiting [#1336](https://github.com/getsentry/sentry-ruby/pull/1336)
|
20
|
+
|
21
|
+
Sentry rate limits different types of events. And when rate limiting is enabled, it sends back a `429` response to the SDK. Currently, the SDK would then raise an error like this:
|
22
|
+
|
23
|
+
```
|
24
|
+
Unable to record event with remote Sentry server (Sentry::Error - the server responded with status 429
|
25
|
+
body: {"detail":"event rejected due to rate limit"}):
|
26
|
+
```
|
27
|
+
|
28
|
+
This change improves the SDK's handling on such responses by:
|
29
|
+
|
30
|
+
- Not treating them as errors, so you don't see the noise anymore.
|
31
|
+
- Halting event sending for a while according to the duration provided in the response. And warns you with a message like:
|
32
|
+
|
33
|
+
```
|
34
|
+
Envelope [event] not sent: Excluded by random sample
|
35
|
+
```
|
36
|
+
|
37
|
+
#### Record request span from Net::HTTP library [#1381](https://github.com/getsentry/sentry-ruby/pull/1381)
|
38
|
+
|
39
|
+
Now any outgoing requests will be recorded as a tracing span. Example:
|
40
|
+
|
41
|
+
<img width="60%" alt="net:http span example" src="https://user-images.githubusercontent.com/5079556/115838944-c1279a80-a44c-11eb-8c67-dfd92bf68bbd.png">
|
42
|
+
|
43
|
+
|
44
|
+
#### Record breadcrumb for Net::HTTP requests [#1394](https://github.com/getsentry/sentry-ruby/pull/1394)
|
45
|
+
|
46
|
+
With the new `http_logger` breadcrumbs logger:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
config.breadcrumbs_logger = [:http_logger]
|
50
|
+
```
|
51
|
+
|
52
|
+
The SDK now records a new `net.http` breadcrumb whenever the user makes a request with the `Net::HTTP` library.
|
53
|
+
|
54
|
+
<img width="60%" alt="net http breadcrumb" src="https://user-images.githubusercontent.com/5079556/114298326-5f7c3d80-9ae8-11eb-9108-222384a7f1a2.png">
|
55
|
+
|
56
|
+
#### Support config.debug configuration option [#1400](https://github.com/getsentry/sentry-ruby/pull/1400)
|
57
|
+
|
58
|
+
It'll determine whether the SDK should run in the debugging mode. Default is `false`. When set to true, SDK errors will be logged with backtrace.
|
59
|
+
|
60
|
+
#### Add the third tracing state [#1402](https://github.com/getsentry/sentry-ruby/pull/1402)
|
61
|
+
- `rate == 0` - Tracing enabled. Rejects all locally created transactions but respects sentry-trace.
|
62
|
+
- `1 > rate > 0` - Tracing enabled. Samples locally created transactions with the rate and respects sentry-trace.
|
63
|
+
- `rate < 0` or `rate > 1` - Tracing disabled.
|
64
|
+
|
65
|
+
### Refactorings
|
66
|
+
|
67
|
+
- Let Transaction constructor take an optional hub argument [#1384](https://github.com/getsentry/sentry-ruby/pull/1384)
|
68
|
+
- Introduce LoggingHelper [#1385](https://github.com/getsentry/sentry-ruby/pull/1385)
|
69
|
+
- Raise exception if a Transaction is initialized without a hub [#1391](https://github.com/getsentry/sentry-ruby/pull/1391)
|
70
|
+
- Make hub a required argument for Transaction constructor [#1401](https://github.com/getsentry/sentry-ruby/pull/1401)
|
71
|
+
|
72
|
+
### Bug Fixes
|
73
|
+
|
74
|
+
- Check `Scope#set_context`'s value argument [#1415](https://github.com/getsentry/sentry-ruby/pull/1415)
|
75
|
+
- Disable tracing if events are not allowed to be sent [#1421](https://github.com/getsentry/sentry-ruby/pull/1421)
|
76
|
+
|
77
|
+
## 4.3.2
|
78
|
+
|
79
|
+
- Correct type attribute's usages [#1354](https://github.com/getsentry/sentry-ruby/pull/1354)
|
80
|
+
- Fix sampling decision precedence [#1335](https://github.com/getsentry/sentry-ruby/pull/1335)
|
81
|
+
- Fix set_contexts [#1375](https://github.com/getsentry/sentry-ruby/pull/1375)
|
82
|
+
- Use thread variable instead of fiber variable to store the hub [#1380](https://github.com/getsentry/sentry-ruby/pull/1380)
|
83
|
+
- Fixes [#1374](https://github.com/getsentry/sentry-ruby/issues/1374)
|
84
|
+
- Fix Span/Transaction's nesting issue [#1382](https://github.com/getsentry/sentry-ruby/pull/1382)
|
85
|
+
- Fixes [#1372](https://github.com/getsentry/sentry-ruby/issues/1372)
|
86
|
+
|
87
|
+
## 4.3.1
|
88
|
+
|
89
|
+
- Add Sentry.set_context helper [#1337](https://github.com/getsentry/sentry-ruby/pull/1337)
|
90
|
+
- Fix handle the case where the logger messages is not of String type [#1341](https://github.com/getsentry/sentry-ruby/pull/1341)
|
91
|
+
- Don't report Sentry::ExternalError to Sentry [#1353](https://github.com/getsentry/sentry-ruby/pull/1353)
|
92
|
+
- Sentry.add_breadcrumb should call Hub#add_breadcrumb [#1358](https://github.com/getsentry/sentry-ruby/pull/1358)
|
93
|
+
- Fixes [#1357](https://github.com/getsentry/sentry-ruby/issues/1357)
|
94
|
+
|
95
|
+
## 4.3.0
|
96
|
+
|
97
|
+
### Features
|
98
|
+
|
99
|
+
- Allow configuring BreadcrumbBuffer's size limit [#1310](https://github.com/getsentry/sentry-ruby/pull/1310)
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
# the SDK will only store 10 breadcrumbs (default is 100)
|
103
|
+
config.max_breadcrumbs = 10
|
104
|
+
```
|
105
|
+
|
106
|
+
- Compress event payload by default [#1314](https://github.com/getsentry/sentry-ruby/pull/1314)
|
107
|
+
|
108
|
+
### Refatorings
|
109
|
+
|
110
|
+
- Refactor interface construction [#1296](https://github.com/getsentry/sentry-ruby/pull/1296)
|
111
|
+
- Refactor tracing implementation [#1309](https://github.com/getsentry/sentry-ruby/pull/1309)
|
112
|
+
|
113
|
+
### Bug Fixes
|
114
|
+
- Improve SDK's error handling [#1298](https://github.com/getsentry/sentry-ruby/pull/1298)
|
115
|
+
- Fixes [#1246](https://github.com/getsentry/sentry-ruby/issues/1246) and [#1289](https://github.com/getsentry/sentry-ruby/issues/1289)
|
116
|
+
- Please read [#1290](https://github.com/getsentry/sentry-ruby/issues/1290) to see the full specification
|
117
|
+
- Treat query string as pii too [#1302](https://github.com/getsentry/sentry-ruby/pull/1302)
|
118
|
+
- Fixes [#1301](https://github.com/getsentry/sentry-ruby/issues/1301)
|
119
|
+
- Ignore sentry-trace when tracing is not enabled [#1308](https://github.com/getsentry/sentry-ruby/pull/1308)
|
120
|
+
- Fixes [#1307](https://github.com/getsentry/sentry-ruby/issues/1307)
|
121
|
+
- Return nil from logger methods instead of breadcrumb buffer [#1299](https://github.com/getsentry/sentry-ruby/pull/1299)
|
122
|
+
- Exceptions with nil message shouldn't cause issues [#1327](https://github.com/getsentry/sentry-ruby/pull/1327)
|
123
|
+
- Fixes [#1323](https://github.com/getsentry/sentry-ruby/issues/1323)
|
124
|
+
- Fix sampling decision with sentry-trace and add more tests [#1326](https://github.com/getsentry/sentry-ruby/pull/1326)
|
125
|
+
|
126
|
+
## 4.2.2
|
127
|
+
|
128
|
+
- Add thread_id to Exception interface [#1291](https://github.com/getsentry/sentry-ruby/pull/1291)
|
129
|
+
- always convert trusted proxies to string [#1288](https://github.com/getsentry/sentry-ruby/pull/1288)
|
130
|
+
- fixes [#1274](https://github.com/getsentry/sentry-ruby/issues/1274)
|
131
|
+
|
132
|
+
## 4.2.1
|
133
|
+
|
134
|
+
### Bug Fixes
|
135
|
+
|
136
|
+
- Ignore invalid values for sentry-trace header that don't match the required format [#1265](https://github.com/getsentry/sentry-ruby/pull/1265)
|
137
|
+
- Transaction created by `.from_sentry_trace` should inherit sampling decision [#1269](https://github.com/getsentry/sentry-ruby/pull/1269)
|
138
|
+
- Transaction's sample rate should accept any numeric value [#1278](https://github.com/getsentry/sentry-ruby/pull/1278)
|
139
|
+
|
140
|
+
## 4.2.0
|
141
|
+
|
142
|
+
### Features
|
143
|
+
|
144
|
+
- Add configuration option for trusted proxies [#1126](https://github.com/getsentry/sentry-ruby/pull/1126)
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
config.trusted_proxies = ["2.2.2.2"] # this ip address will be skipped when computing users' ip addresses
|
148
|
+
```
|
149
|
+
|
150
|
+
- Add ThreadsInterface [#1178](https://github.com/getsentry/sentry-ruby/pull/1178)
|
151
|
+
|
152
|
+
<img width="1029" alt="an exception event that has the new threads interface" src="https://user-images.githubusercontent.com/5079556/103459223-98b64c00-4d48-11eb-9ebb-ee58f15e647e.png">
|
153
|
+
|
154
|
+
- Support `config.before_breadcrumb` [#1253](https://github.com/getsentry/sentry-ruby/pull/1253)
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
# this will be called before every breadcrumb is added to the breadcrumb buffer
|
158
|
+
# you can use it to
|
159
|
+
# - remove the data you don't want to send
|
160
|
+
# - add additional info to the data
|
161
|
+
config.before_breadcrumb = lambda do |breadcrumb, hint|
|
162
|
+
breadcrumb.message = "foo"
|
163
|
+
breadcrumb
|
164
|
+
end
|
165
|
+
```
|
166
|
+
|
167
|
+
- Add ability to have many post initialization callbacks [#1261](https://github.com/getsentry/sentry-ruby/pull/1261)
|
168
|
+
|
169
|
+
### Bug Fixes
|
170
|
+
|
171
|
+
- Inspect exception cause by default & don't exclude ActiveJob::DeserializationError [#1180](https://github.com/getsentry/sentry-ruby/pull/1180)
|
172
|
+
- Fixes [#1071](https://github.com/getsentry/sentry-ruby/issues/1071)
|
173
|
+
|
3
174
|
## 4.1.6
|
4
175
|
|
5
176
|
- Don't detect project root for Rails apps [#1243](https://github.com/getsentry/sentry-ruby/pull/1243)
|
@@ -140,4 +311,3 @@ Fix require reference
|
|
140
311
|
## 0.1.0
|
141
312
|
|
142
313
|
First version
|
143
|
-
|
data/Gemfile
CHANGED
@@ -3,15 +3,18 @@ source "https://rubygems.org"
|
|
3
3
|
gem "sentry-ruby-core", path: "./"
|
4
4
|
gem "sentry-ruby", path: "./"
|
5
5
|
|
6
|
-
|
7
|
-
gem "i18n", "<= 1.8.7"
|
6
|
+
gem "rack" unless ENV["WITHOUT_RACK"] == "1"
|
8
7
|
|
9
8
|
gem "rake", "~> 12.0"
|
10
9
|
gem "rspec", "~> 3.0"
|
10
|
+
gem "rspec-retry"
|
11
|
+
gem "webmock"
|
12
|
+
gem "timecop"
|
11
13
|
gem "codecov", "0.2.12"
|
12
14
|
|
15
|
+
gem "object_tracer"
|
16
|
+
gem "debug", github: "ruby/debug" if RUBY_VERSION.to_f >= 2.6
|
13
17
|
gem "pry"
|
14
|
-
gem "rack" unless ENV["WITHOUT_RACK"] == "1"
|
15
18
|
|
16
19
|
gem "benchmark-ips"
|
17
20
|
gem "benchmark_driver"
|
data/README.md
CHANGED
@@ -2,38 +2,36 @@
|
|
2
2
|
<a href="https://sentry.io" target="_blank" align="center">
|
3
3
|
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
|
4
4
|
</a>
|
5
|
-
<br
|
5
|
+
<br />
|
6
6
|
</p>
|
7
7
|
|
8
|
-
|
8
|
+
_Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us [<kbd>**Check out our open positions**</kbd>](https://sentry.io/careers/)_
|
9
9
|
|
10
|
-
|
10
|
+
Sentry SDK for Ruby
|
11
|
+
===========
|
11
12
|
|
12
|
-
|
13
|
+
| current version | build | coverage | downloads | semver stability |
|
14
|
+
| --- | ----- | -------- | --------- | ---------------- |
|
15
|
+
| [![Gem Version](https://img.shields.io/gem/v/sentry-ruby?label=sentry-ruby)](https://github.com/getsentry/sentry-ruby/blob/master/sentry-ruby/CHANGELOG.md) | ![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-ruby%20Test/badge.svg) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-ruby.svg)](https://rubygems.org/gems/sentry-ruby/) | [![SemVer stability](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-ruby&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-ruby&package-manager=bundler&version-scheme=semver) |
|
16
|
+
| [![Gem Version](https://img.shields.io/gem/v/sentry-rails?label=sentry-rails)](https://github.com/getsentry/sentry-ruby/blob/master/sentry-rails/CHANGELOG.md) | ![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-rails%20Test/badge.svg) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-rails.svg)](https://rubygems.org/gems/sentry-rails/) | [![SemVer stability](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-rails&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-rails&package-manager=bundler&version-scheme=semver) |
|
17
|
+
| [![Gem Version](https://img.shields.io/gem/v/sentry-sidekiq?label=sentry-sidekiq)](https://github.com/getsentry/sentry-ruby/blob/master/sentry-sidekiq/CHANGELOG.md) | ![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-sidekiq%20Test/badge.svg) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-sidekiq.svg)](https://rubygems.org/gems/sentry-sidekiq/) | [![SemVer stability](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-sidekiq&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-sidekiq&package-manager=bundler&version-scheme=semver) |
|
18
|
+
| [![Gem Version](https://img.shields.io/gem/v/sentry-delayed_job?label=sentry-delayed_job)](https://github.com/getsentry/sentry-ruby/blob/master/sentry-delayed_job/CHANGELOG.md) | ![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-delayed_job%20Test/badge.svg) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-delayed_job.svg)](https://rubygems.org/gems/sentry-delayed_job/) | [![SemVer stability](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-delayed_job&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-delayed_job&package-manager=bundler&version-scheme=semver) |
|
13
19
|
|
14
20
|
|
15
|
-
[![Gem Version](https://img.shields.io/gem/v/sentry-ruby.svg)](https://rubygems.org/gems/sentry-ruby)
|
16
|
-
![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-ruby%20Test/badge.svg)
|
17
|
-
[![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master)
|
18
|
-
[![Gem](https://img.shields.io/gem/dt/sentry-ruby.svg)](https://rubygems.org/gems/sentry-ruby/)
|
19
|
-
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-ruby&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-ruby&package-manager=bundler&version-scheme=semver)
|
20
21
|
|
21
22
|
|
22
|
-
|
23
|
+
## Migrate From sentry-raven
|
23
24
|
|
24
|
-
The
|
25
|
+
**The old `sentry-raven` client has entered maintenance mode and was moved to [here](https://github.com/getsentry/sentry-ruby/tree/master/sentry-raven).**
|
25
26
|
|
27
|
+
If you're using `sentry-raven`, we recommend you to migrate to this new SDK. You can find the benefits of migrating and how to do it in our [migration guide](https://docs.sentry.io/platforms/ruby/migration/).
|
26
28
|
|
27
29
|
## Requirements
|
28
30
|
|
29
|
-
We test on Ruby 2.4, 2.5, 2.6
|
31
|
+
We test on Ruby 2.4, 2.5, 2.6, 2.7, and 3.0 at the latest patchlevel/teeny version. We also support JRuby 9.0.
|
30
32
|
|
31
33
|
If you use self-hosted Sentry, please also make sure its version is above `20.6.0`.
|
32
34
|
|
33
|
-
## Migrate From sentry-raven
|
34
|
-
|
35
|
-
If you're using `sentry-raven`, we recommend you to migrate to this new SDK. You can find the benefits of migrating and how to do it in our [migration guide](https://docs.sentry.io/platforms/ruby/migration/).
|
36
|
-
|
37
35
|
## Getting Started
|
38
36
|
|
39
37
|
### Install
|
@@ -47,6 +45,7 @@ and depends on the integrations you want to have, you might also want to install
|
|
47
45
|
```ruby
|
48
46
|
gem "sentry-rails"
|
49
47
|
gem "sentry-sidekiq"
|
48
|
+
gem "sentry-delayed_job"
|
50
49
|
# and mores to come in the future!
|
51
50
|
```
|
52
51
|
|
@@ -67,7 +66,7 @@ end
|
|
67
66
|
|
68
67
|
### Sentry doesn't report some kinds of data by default
|
69
68
|
|
70
|
-
**Sentry ignores some exceptions by default** - most of these are related to 404s parameter parsing errors. [For a complete list, see the `IGNORE_DEFAULT` constant](https://github.com/getsentry/sentry-ruby/blob/master/sentry-ruby/lib/sentry/configuration.rb#
|
69
|
+
**Sentry ignores some exceptions by default** - most of these are related to 404s parameter parsing errors. [For a complete list, see the `IGNORE_DEFAULT` constant](https://github.com/getsentry/sentry-ruby/blob/master/sentry-ruby/lib/sentry/configuration.rb#L151) and the integration gems' `IGNORE_DEFAULT`, like [`sentry-rails`'s](https://github.com/getsentry/sentry-ruby/blob/master/sentry-rails/lib/sentry/rails/configuration.rb#L12)
|
71
70
|
|
72
71
|
Sentry doesn't send personally identifiable information (pii) by default, such as request body, user ip or cookies. If you want those information to be sent, you can use the `send_default_pii` config option:
|
73
72
|
|
@@ -136,6 +135,7 @@ We also provide integrations with popular frameworks/libraries with the related
|
|
136
135
|
|
137
136
|
- [sentry-rails](https://github.com/getsentry/sentry-ruby/tree/master/sentry-rails)
|
138
137
|
- [sentry-sidekiq](https://github.com/getsentry/sentry-ruby/tree/master/sentry-sidekiq)
|
138
|
+
- [sentry-delayed_job](https://github.com/getsentry/sentry-ruby/tree/master/sentry-delayed_job)
|
139
139
|
|
140
140
|
### More configuration
|
141
141
|
|
@@ -143,32 +143,7 @@ You're all set - but there's a few more settings you may want to know about too!
|
|
143
143
|
|
144
144
|
#### Blocking v.s. Non-blocking
|
145
145
|
|
146
|
-
|
147
|
-
|
148
|
-
```ruby
|
149
|
-
config.async = lambda { |event, hint|
|
150
|
-
Thread.new { Sentry.send_event(event, hint) }
|
151
|
-
}
|
152
|
-
```
|
153
|
-
|
154
|
-
Using a thread to send events will be adequate for truly parallel Ruby platforms such as JRuby, though the benefit on MRI/CRuby will be limited. If the async callback raises an exception, Sentry will attempt to send synchronously.
|
155
|
-
|
156
|
-
Note that the naive example implementation has a major drawback - it can create an infinite number of threads. We recommend creating a background job, using your background job processor, that will send Sentry notifications in the background.
|
157
|
-
|
158
|
-
```ruby
|
159
|
-
config.async = lambda { |event, hint| SentryJob.perform_later(event, hint) }
|
160
|
-
|
161
|
-
class SentryJob < ActiveJob::Base
|
162
|
-
queue_as :default
|
163
|
-
|
164
|
-
def perform(event, hint)
|
165
|
-
Sentry.send_event(event, hint)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
```
|
169
|
-
|
170
|
-
|
171
|
-
**After version 4.1.0**, `sentry-ruby` sends events asynchronously by default. The functionality works like this:
|
146
|
+
`sentry-ruby` sends events asynchronously by default. The functionality works like this:
|
172
147
|
|
173
148
|
1. When the SDK is initialized, a `Sentry::BackgroundWorker` will be initialized too.
|
174
149
|
2. When an event is passed to `Client#capture_event`, instead of sending it directly with `Client#send_event`, we'll let the worker do it.
|
@@ -202,6 +177,21 @@ If you want to send a particular event immediately, you can use event hints to d
|
|
202
177
|
Sentry.capture_message("send me now!", hint: { background: false })
|
203
178
|
```
|
204
179
|
|
180
|
+
##### `config.async`
|
181
|
+
|
182
|
+
You can also use `config.async` to send events with you own worker:
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
config.async = lambda { |event, hint| SentryJob.perform_later(event, hint) }
|
186
|
+
```
|
187
|
+
|
188
|
+
And if you use `sentry-rails`, you can directly use the job we defined for you:
|
189
|
+
|
190
|
+
```ruby
|
191
|
+
config.async = lambda { |event, hint| Sentry::SendEventJob.perform_later(event, hint) }
|
192
|
+
```
|
193
|
+
|
194
|
+
|
205
195
|
#### Contexts
|
206
196
|
|
207
197
|
In sentry-ruby, every event will inherit their contextual data from the current scope. So you can enrich the event's data by configuring the current scope like:
|
@@ -251,10 +241,10 @@ Of course, you can always assign the information on a per-event basis:
|
|
251
241
|
Sentry.capture_exception(exception, tags: {foo: "bar"})
|
252
242
|
```
|
253
243
|
|
254
|
-
##
|
255
|
-
|
256
|
-
* [Documentation](https://docs.sentry.io/platforms/ruby/)
|
257
|
-
* [Bug Tracker](https://github.com/getsentry/sentry-ruby/issues)
|
258
|
-
* [Forum](https://forum.sentry.io/)
|
259
|
-
- [Discord](https://discord.gg/ez5KZN7)
|
244
|
+
## Resources
|
260
245
|
|
246
|
+
* [![Ruby docs](https://img.shields.io/badge/documentation-sentry.io-green.svg?label=ruby%20docs)](https://docs.sentry.io/platforms/ruby/)
|
247
|
+
* [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks)
|
248
|
+
* [![Discord Chat](https://img.shields.io/discord/621778831602221064?logo=discord&logoColor=ffffff&color=7389D8)](https://discord.gg/PXa5Apfe7K)
|
249
|
+
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](https://stackoverflow.com/questions/tagged/sentry)
|
250
|
+
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)
|
data/lib/sentry-ruby.rb
CHANGED
@@ -3,8 +3,10 @@ require "forwardable"
|
|
3
3
|
require "time"
|
4
4
|
|
5
5
|
require "sentry/version"
|
6
|
+
require "sentry/exceptions"
|
6
7
|
require "sentry/core_ext/object/deep_dup"
|
7
8
|
require "sentry/utils/argument_checking_helper"
|
9
|
+
require "sentry/utils/logging_helper"
|
8
10
|
require "sentry/configuration"
|
9
11
|
require "sentry/logger"
|
10
12
|
require "sentry/event"
|
@@ -26,13 +28,12 @@ require "sentry/background_worker"
|
|
26
28
|
end
|
27
29
|
|
28
30
|
module Sentry
|
29
|
-
class Error < StandardError
|
30
|
-
end
|
31
|
-
|
32
31
|
META = { "name" => "sentry.ruby", "version" => Sentry::VERSION }.freeze
|
33
32
|
|
34
33
|
LOGGER_PROGNAME = "sentry".freeze
|
35
34
|
|
35
|
+
SENTRY_TRACE_HEADER_NAME = "sentry-trace".freeze
|
36
|
+
|
36
37
|
THREAD_LOCAL = :sentry_hub
|
37
38
|
|
38
39
|
def self.sdk_meta
|
@@ -60,17 +61,34 @@ module Sentry
|
|
60
61
|
extend Forwardable
|
61
62
|
|
62
63
|
def_delegators :get_current_client, :configuration, :send_event
|
63
|
-
def_delegators :get_current_scope, :set_tags, :set_extras, :set_user
|
64
|
+
def_delegators :get_current_scope, :set_tags, :set_extras, :set_user, :set_context
|
64
65
|
|
65
66
|
attr_accessor :background_worker
|
66
67
|
|
68
|
+
@@registered_patches = []
|
69
|
+
|
70
|
+
def register_patch(&block)
|
71
|
+
registered_patches << block
|
72
|
+
end
|
73
|
+
|
74
|
+
def apply_patches(config)
|
75
|
+
registered_patches.each do |patch|
|
76
|
+
patch.call(config)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def registered_patches
|
81
|
+
@@registered_patches
|
82
|
+
end
|
83
|
+
|
67
84
|
def init(&block)
|
68
85
|
config = Configuration.new
|
69
86
|
yield(config) if block_given?
|
87
|
+
apply_patches(config)
|
70
88
|
client = Client.new(config)
|
71
|
-
scope = Scope.new
|
89
|
+
scope = Scope.new(max_breadcrumbs: config.max_breadcrumbs)
|
72
90
|
hub = Hub.new(client, scope)
|
73
|
-
Thread.current
|
91
|
+
Thread.current.thread_variable_set(THREAD_LOCAL, hub)
|
74
92
|
@main_hub = hub
|
75
93
|
@background_worker = Sentry::BackgroundWorker.new(config)
|
76
94
|
end
|
@@ -82,7 +100,7 @@ module Sentry
|
|
82
100
|
|
83
101
|
# Takes an instance of Sentry::Breadcrumb and stores it to the current active scope.
|
84
102
|
def add_breadcrumb(breadcrumb)
|
85
|
-
|
103
|
+
get_current_hub&.add_breadcrumb(breadcrumb)
|
86
104
|
end
|
87
105
|
|
88
106
|
# Returns the current active hub.
|
@@ -94,7 +112,7 @@ module Sentry
|
|
94
112
|
# ideally, we should do this proactively whenever a new thread is created
|
95
113
|
# but it's impossible for the SDK to keep track every new thread
|
96
114
|
# so we need to use this rather passive way to make sure the app doesn't crash
|
97
|
-
Thread.current
|
115
|
+
Thread.current.thread_variable_get(THREAD_LOCAL) || clone_hub_to_current_thread
|
98
116
|
end
|
99
117
|
|
100
118
|
# Returns the current active client.
|
@@ -109,7 +127,7 @@ module Sentry
|
|
109
127
|
|
110
128
|
# Clones the main thread's active hub and stores it to the current thread.
|
111
129
|
def clone_hub_to_current_thread
|
112
|
-
Thread.current
|
130
|
+
Thread.current.thread_variable_set(THREAD_LOCAL, get_main_hub.clone)
|
113
131
|
end
|
114
132
|
|
115
133
|
# Takes a block and yields the current active scope.
|
@@ -190,3 +208,6 @@ module Sentry
|
|
190
208
|
end
|
191
209
|
end
|
192
210
|
end
|
211
|
+
|
212
|
+
# patches
|
213
|
+
require "sentry/net/http"
|