sentry-ruby 5.3.1 → 5.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.yardopts +2 -0
  5. data/CHANGELOG.md +313 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +27 -0
  8. data/Makefile +4 -0
  9. data/Rakefile +13 -0
  10. data/bin/console +18 -0
  11. data/bin/setup +8 -0
  12. data/lib/sentry/background_worker.rb +72 -0
  13. data/lib/sentry/backtrace.rb +124 -0
  14. data/lib/sentry/breadcrumb/sentry_logger.rb +90 -0
  15. data/lib/sentry/breadcrumb.rb +70 -0
  16. data/lib/sentry/breadcrumb_buffer.rb +64 -0
  17. data/lib/sentry/client.rb +190 -0
  18. data/lib/sentry/configuration.rb +502 -0
  19. data/lib/sentry/core_ext/object/deep_dup.rb +61 -0
  20. data/lib/sentry/core_ext/object/duplicable.rb +155 -0
  21. data/lib/sentry/dsn.rb +53 -0
  22. data/lib/sentry/envelope.rb +96 -0
  23. data/lib/sentry/error_event.rb +38 -0
  24. data/lib/sentry/event.rb +178 -0
  25. data/lib/sentry/exceptions.rb +9 -0
  26. data/lib/sentry/hub.rb +220 -0
  27. data/lib/sentry/integrable.rb +26 -0
  28. data/lib/sentry/interface.rb +16 -0
  29. data/lib/sentry/interfaces/exception.rb +43 -0
  30. data/lib/sentry/interfaces/request.rb +144 -0
  31. data/lib/sentry/interfaces/single_exception.rb +57 -0
  32. data/lib/sentry/interfaces/stacktrace.rb +87 -0
  33. data/lib/sentry/interfaces/stacktrace_builder.rb +79 -0
  34. data/lib/sentry/interfaces/threads.rb +42 -0
  35. data/lib/sentry/linecache.rb +47 -0
  36. data/lib/sentry/logger.rb +20 -0
  37. data/lib/sentry/net/http.rb +115 -0
  38. data/lib/sentry/rack/capture_exceptions.rb +80 -0
  39. data/lib/sentry/rack.rb +5 -0
  40. data/lib/sentry/rake.rb +41 -0
  41. data/lib/sentry/redis.rb +90 -0
  42. data/lib/sentry/release_detector.rb +39 -0
  43. data/lib/sentry/scope.rb +295 -0
  44. data/lib/sentry/session.rb +35 -0
  45. data/lib/sentry/session_flusher.rb +90 -0
  46. data/lib/sentry/span.rb +226 -0
  47. data/lib/sentry/test_helper.rb +76 -0
  48. data/lib/sentry/transaction.rb +206 -0
  49. data/lib/sentry/transaction_event.rb +29 -0
  50. data/lib/sentry/transport/configuration.rb +25 -0
  51. data/lib/sentry/transport/dummy_transport.rb +21 -0
  52. data/lib/sentry/transport/http_transport.rb +175 -0
  53. data/lib/sentry/transport.rb +210 -0
  54. data/lib/sentry/utils/argument_checking_helper.rb +13 -0
  55. data/lib/sentry/utils/custom_inspection.rb +14 -0
  56. data/lib/sentry/utils/exception_cause_chain.rb +20 -0
  57. data/lib/sentry/utils/logging_helper.rb +26 -0
  58. data/lib/sentry/utils/real_ip.rb +84 -0
  59. data/lib/sentry/utils/request_id.rb +18 -0
  60. data/lib/sentry/version.rb +5 -0
  61. data/lib/sentry-ruby.rb +505 -0
  62. data/sentry-ruby-core.gemspec +23 -0
  63. data/sentry-ruby.gemspec +24 -0
  64. metadata +64 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b786b31a88128e126c760bb9eecb0b75e3cc8d97549cdf755de4ec2c82cab687
4
- data.tar.gz: 50894df8dffb30dfac38da8a7015f5b14bfc795006207caa472a07cb8d3dbc1d
3
+ metadata.gz: a63e249dfaf6fb45c9a4cfb897b604e96cb751b12920aa7371c8f503754001fd
4
+ data.tar.gz: b27555038074ec03421cc287dbecf2fa7e85642c4bffaa71bb770232dc6eb4d1
5
5
  SHA512:
6
- metadata.gz: 4fa4eecba33de6670e1dbf7d2b61928122ff7d2e248fbcc09550d6b9ebeadea2fba234216c5a2db9bbc8707219cbf0fd1db81cb73efd9785cb0ab5f0ea793b00
7
- data.tar.gz: aaedf0e1cceb93b91da0a8d470ae4a88a674ff6ca406318fcebf06763ae4cbc501f745a25d63f7d991b51d71eab18d3043a7cda53c25ae895c12f91dcc7df813
6
+ metadata.gz: 3dd63a8eeadb199013c7c2387819e185f58751d733cf6c36f4a95d1653e85bca20b62b75ccea24f8c624eaffc3f4a5c1d2889352e6e4b80744ecc2974981a9bd
7
+ data.tar.gz: ef0594cbf709b46819b970debebec8f2a5be3f49aa483ea15963640af3ab84ea9c180ffbf6138675d8354d840106fca5e4e178d1f40e13e22b5ff57b60402e83
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --exclude lib/sentry/utils/
2
+ --exclude lib/sentry/core_ext
data/CHANGELOG.md ADDED
@@ -0,0 +1,313 @@
1
+ # Changelog
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
+
174
+ ## 4.1.6
175
+
176
+ - Don't detect project root for Rails apps [#1243](https://github.com/getsentry/sentry-ruby/pull/1243)
177
+ - Separate individual breadcrumb's data serialization [#1250](https://github.com/getsentry/sentry-ruby/pull/1250)
178
+ - Capture sentry-trace with the correct http header key [#1260](https://github.com/getsentry/sentry-ruby/pull/1260)
179
+
180
+ ## 4.1.5
181
+
182
+ - Serialize event hint before passing it to the async block [#1231](https://github.com/getsentry/sentry-ruby/pull/1231)
183
+ - Fixes [#1227](https://github.com/getsentry/sentry-ruby/issues/1227)
184
+ - Require the English library [#1233](https://github.com/getsentry/sentry-ruby/pull/1233) (by @dentarg)
185
+ - Allow `Sentry.init` without block argument [#1235](https://github.com/getsentry/sentry-ruby/pull/1235) (by @sue445)
186
+
187
+ ## 4.1.5-beta.1
188
+
189
+ - No change
190
+
191
+ ## 4.1.5-beta.0
192
+
193
+ - Inline global method [#1213](https://github.com/getsentry/sentry-ruby/pull/1213) (by @tricknotes)
194
+ - Event message and exception message should have a size limit [#1221](https://github.com/getsentry/sentry-ruby/pull/1221)
195
+ - Add sentry-ruby-core as a more flexible option [#1226](https://github.com/getsentry/sentry-ruby/pull/1226)
196
+
197
+ ## 4.1.4
198
+
199
+ - Fix headers serialization for sentry-ruby [#1197](https://github.com/getsentry/sentry-ruby/pull/1197) (by @moofkit)
200
+ - Support capturing "sentry-trace" header from the middleware [#1205](https://github.com/getsentry/sentry-ruby/pull/1205)
201
+ - Document public APIs on the Sentry module [#1208](https://github.com/getsentry/sentry-ruby/pull/1208)
202
+ - Check the argument type of capture_exception and capture_event helpers [#1209](https://github.com/getsentry/sentry-ruby/pull/1209)
203
+
204
+ ## 4.1.3
205
+
206
+ - rm reference to old constant (from Rails v2.2) [#1184](https://github.com/getsentry/sentry-ruby/pull/1184)
207
+ - Use copied env in events [#1186](https://github.com/getsentry/sentry-ruby/pull/1186)
208
+ - Fixes [#1183](https://github.com/getsentry/sentry-ruby/issues/1183)
209
+ - Refactor RequestInterface [#1187](https://github.com/getsentry/sentry-ruby/pull/1187)
210
+ - Supply event hint to async callback when possible [#1189](https://github.com/getsentry/sentry-ruby/pull/1189)
211
+ - Fixes [#1188](https://github.com/getsentry/sentry-ruby/issues/1188)
212
+ - Refactor stacktrace parsing and increase test coverage [#1190](https://github.com/getsentry/sentry-ruby/pull/1190)
213
+ - Sentry.send_event should also take a hint [#1192](https://github.com/getsentry/sentry-ruby/pull/1192)
214
+
215
+ ## 4.1.2
216
+
217
+ - before_send callback shouldn't be applied to transaction events [#1167](https://github.com/getsentry/sentry-ruby/pull/1167)
218
+ - Transaction improvements [#1170](https://github.com/getsentry/sentry-ruby/pull/1170)
219
+ - Support Ruby 3 [#1172](https://github.com/getsentry/sentry-ruby/pull/1172)
220
+ - Add Integrable module [#1177](https://github.com/getsentry/sentry-ruby/pull/1177)
221
+
222
+ ## 4.1.1
223
+
224
+ - Fix NoMethodError when sending is not allowed [#1161](https://github.com/getsentry/sentry-ruby/pull/1161)
225
+ - Add notification for users who still use deprecated middlewares [#1160](https://github.com/getsentry/sentry-ruby/pull/1160)
226
+ - Improve top-level api safety [#1162](https://github.com/getsentry/sentry-ruby/pull/1162)
227
+
228
+ ## 4.1.0
229
+
230
+ - Separate rack integration [#1138](https://github.com/getsentry/sentry-ruby/pull/1138)
231
+ - Fixes [#1136](https://github.com/getsentry/sentry-ruby/pull/1136)
232
+ - Fix event sampling [#1144](https://github.com/getsentry/sentry-ruby/pull/1144)
233
+ - Merge & rename 2 Rack middlewares [#1147](https://github.com/getsentry/sentry-ruby/pull/1147)
234
+ - Fixes [#1153](https://github.com/getsentry/sentry-ruby/pull/1153)
235
+ - Removed `Sentry::Rack::Tracing` middleware and renamed `Sentry::Rack::CaptureException` to `Sentry::Rack::CaptureExceptions`.
236
+ - Deep-copy spans [#1148](https://github.com/getsentry/sentry-ruby/pull/1148)
237
+ - Move span recorder related code from Span to Transaction [#1149](https://github.com/getsentry/sentry-ruby/pull/1149)
238
+ - Check SDK initialization before running integrations [#1151](https://github.com/getsentry/sentry-ruby/pull/1151)
239
+ - Fixes [#1145](https://github.com/getsentry/sentry-ruby/pull/1145)
240
+ - Refactor transport [#1154](https://github.com/getsentry/sentry-ruby/pull/1154)
241
+ - Implement non-blocking event sending [#1155](https://github.com/getsentry/sentry-ruby/pull/1155)
242
+ - Added `background_worker_threads` configuration option.
243
+
244
+ ### Noticeable Changes
245
+
246
+ #### Middleware Changes
247
+
248
+ `Sentry::Rack::Tracing` is now removed. And `Sentry::Rack::CaptureException` has been renamed to `Sentry::Rack::CaptureExceptions`.
249
+
250
+ #### Events Are Sent Asynchronously
251
+
252
+ `sentry-ruby` now sends events asynchronously by default. The functionality works like this:
253
+
254
+ 1. When the SDK is initialized, a `Sentry::BackgroundWorker` will be initialized too.
255
+ 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.
256
+ 3. The worker will have a number of threads. And the one of the idle threads will pick the job and call `Client#send_event`.
257
+ - If all the threads are busy, new jobs will be put into a queue, which has a limit of 30.
258
+ - If the queue size is exceeded, new events will be dropped.
259
+
260
+ However, if you still prefer to use your own async approach, that's totally fine. If you have `config.async` set, the worker won't initialize a thread pool and won't be used either.
261
+
262
+ This functionality also introduces a new `background_worker_threads` config option. It allows you to decide how many threads should the worker hold. By default, the value will be the number of the processors your machine has. For example, if your machine has 4 processors, the value would be 4.
263
+
264
+ Of course, you can always override the value to fit your use cases, like
265
+
266
+ ```ruby
267
+ config.background_worker_threads = 5 # the worker will have 5 threads for sending events
268
+ ```
269
+
270
+ You can also disable this new non-blocking behaviour by giving a `0` value:
271
+
272
+ ```ruby
273
+ config.background_worker_threads = 0 # all events will be sent synchronously
274
+ ```
275
+
276
+ ## 4.0.1
277
+
278
+ - Add rake integration: [1137](https://github.com/getsentry/sentry-ruby/pull/1137)
279
+ - Make Event's interfaces accessible: [1135](https://github.com/getsentry/sentry-ruby/pull/1135)
280
+ - ActiveSupportLogger should only record events that has a started time: [1132](https://github.com/getsentry/sentry-ruby/pull/1132)
281
+
282
+ ## 4.0.0
283
+
284
+ - Only documents update for the official release and no API/feature changes.
285
+
286
+ ## 0.3.0
287
+
288
+ - Major API changes: [1123](https://github.com/getsentry/sentry-ruby/pull/1123)
289
+ - Support event hint: [1122](https://github.com/getsentry/sentry-ruby/pull/1122)
290
+ - Add request-id tag to events: [1120](https://github.com/getsentry/sentry-ruby/pull/1120) (by @tvec)
291
+
292
+ ## 0.2.0
293
+
294
+ - Multiple fixes and refactorings
295
+ - Tracing support
296
+
297
+ ## 0.1.3
298
+
299
+ Fix require reference
300
+
301
+ ## 0.1.2
302
+
303
+ - Fix: Fix async callback [1098](https://github.com/getsentry/sentry-ruby/pull/1098)
304
+ - Refactor: Some code cleanup [1100](https://github.com/getsentry/sentry-ruby/pull/1100)
305
+ - Refactor: Remove Event options [1101](https://github.com/getsentry/sentry-ruby/pull/1101)
306
+
307
+ ## 0.1.1
308
+
309
+ - Feature: Allow passing custom scope to Hub#capture* helpers [1086](https://github.com/getsentry/sentry-ruby/pull/1086)
310
+
311
+ ## 0.1.0
312
+
313
+ First version
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at stan001212@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,27 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) { |name| "https://github.com/#{name}.git" }
3
+
4
+ gem "sentry-ruby", path: "./"
5
+
6
+ gem "rack" unless ENV["WITHOUT_RACK"] == "1"
7
+
8
+ gem "rake", "~> 12.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "rspec-retry"
11
+ gem "webmock"
12
+ gem "fakeredis"
13
+ gem "timecop"
14
+ gem 'simplecov'
15
+ gem "simplecov-cobertura", "~> 1.4"
16
+ gem "rexml"
17
+
18
+ gem "object_tracer"
19
+ gem "debug", github: "ruby/debug", platform: :ruby if RUBY_VERSION.to_f >= 2.6
20
+ gem "pry"
21
+
22
+ gem "benchmark-ips"
23
+ gem "benchmark_driver"
24
+ gem "benchmark-ipsa"
25
+ gem "benchmark-memory"
26
+
27
+ gem "yard", "~> 0.9.27"
data/Makefile ADDED
@@ -0,0 +1,4 @@
1
+ build:
2
+ bundle install
3
+ gem build sentry-ruby-core.gemspec
4
+ gem build sentry-ruby.gemspec
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "rake/clean"
2
+ CLOBBER.include "pkg"
3
+
4
+ require "bundler/gem_helper"
5
+ Bundler::GemHelper.install_tasks(name: "sentry-ruby")
6
+
7
+ require "rspec/core/rake_task"
8
+
9
+ RSpec::Core::RakeTask.new(:spec).tap do |task|
10
+ task.rspec_opts = "--order rand"
11
+ end
12
+
13
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sentry-ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ # Sentry.init do |config|
14
+ # config.dsn = 'https://2fb45f003d054a7ea47feb45898f7649@o447951.ingest.sentry.io/5434472'
15
+ # end
16
+
17
+ require "irb"
18
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "concurrent/executor/thread_pool_executor"
4
+ require "concurrent/executor/immediate_executor"
5
+ require "concurrent/configuration"
6
+
7
+ module Sentry
8
+ class BackgroundWorker
9
+ include LoggingHelper
10
+
11
+ attr_reader :max_queue, :number_of_threads
12
+ # @deprecated Use Sentry.logger to retrieve the current logger instead.
13
+ attr_reader :logger
14
+ attr_accessor :shutdown_timeout
15
+
16
+ def initialize(configuration)
17
+ @max_queue = 30
18
+ @shutdown_timeout = 1
19
+ @number_of_threads = configuration.background_worker_threads
20
+ @logger = configuration.logger
21
+ @debug = configuration.debug
22
+ @shutdown_callback = nil
23
+
24
+ @executor =
25
+ if configuration.async
26
+ log_debug("config.async is set, BackgroundWorker is disabled")
27
+ Concurrent::ImmediateExecutor.new
28
+ elsif @number_of_threads == 0
29
+ log_debug("config.background_worker_threads is set to 0, all events will be sent synchronously")
30
+ Concurrent::ImmediateExecutor.new
31
+ else
32
+ log_debug("Initializing the background worker with #{@number_of_threads} threads")
33
+
34
+ executor = Concurrent::ThreadPoolExecutor.new(
35
+ min_threads: 0,
36
+ max_threads: @number_of_threads,
37
+ max_queue: @max_queue,
38
+ fallback_policy: :discard
39
+ )
40
+
41
+ @shutdown_callback = proc do
42
+ executor.shutdown
43
+ executor.wait_for_termination(@shutdown_timeout)
44
+ end
45
+
46
+ executor
47
+ end
48
+ end
49
+
50
+ # if you want to monkey-patch this method, please override `_perform` instead
51
+ def perform(&block)
52
+ @executor.post do
53
+ begin
54
+ _perform(&block)
55
+ rescue Exception => e
56
+ log_error("exception happened in background worker", e, debug: @debug)
57
+ end
58
+ end
59
+ end
60
+
61
+ def shutdown
62
+ log_debug("Shutting down background worker")
63
+ @shutdown_callback&.call
64
+ end
65
+
66
+ private
67
+
68
+ def _perform(&block)
69
+ block.call
70
+ end
71
+ end
72
+ end