raygun4ruby 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +26 -0
- data/lib/raygun/sidekiq.rb +31 -5
- data/lib/raygun/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30c96f5c697418070d9887e7bd698f3d560c50ea
|
4
|
+
data.tar.gz: 3320b9b575ddbc04a06e61b26bb848b30d4e4c7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef94e8d1e90c14929c84b5d13bfa3ecd868379c422113f94b0116f109273a5c2c97182001e2eb52bc9f4898233df4420d4ab28fa14cf77acfed34273fa5f01d6
|
7
|
+
data.tar.gz: ebf0bd808d57af7b29fac0326f8b79b380461bede714f9db014845b8dbf78933f354559a31d8158e6a18c831667689a0960180b3776e8232425ab7abedea071e
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
## 2.
|
1
|
+
## 2.4.0 (31/07/2017)
|
2
|
+
|
3
|
+
Features
|
4
|
+
- Add functionality to track affected user in Sidekiq jobs, refer to the README for more information, under the "Affected User Tracking in Sidekiq" heading ([#121](https://github.com/MindscapeHQ/raygun4ruby/pull/121))
|
5
|
+
## 2.3.0 (09/05/2017)"
|
2
6
|
|
3
7
|
Bugfixes
|
4
8
|
- Fix issue preventing affected users for a crash report from showing up in the affected users page ([#119](https://github.com/MindscapeHQ/raygun4ruby/pull/119))
|
data/README.md
CHANGED
@@ -352,6 +352,32 @@ Raygun4Ruby can track errors from Sidekiq (2.x or 3+). All you need to do is add
|
|
352
352
|
|
353
353
|
Either in your Raygun initializer or wherever else takes your fancy :)
|
354
354
|
|
355
|
+
#### Affected User Tracking in Sidekiq
|
356
|
+
|
357
|
+
To track affected users, define a class method on your worker class that returns a user object.
|
358
|
+
Make sure the name of this method is the same as whatever you have defined as the `affected_user_method` in your Raygun configuration and that it returns an object that fits the mappings defined in `affected_user_mapping`
|
359
|
+
If you have not changed these, refer to [Affected user tracking](#affected-user-tracking) for the defaults
|
360
|
+
|
361
|
+
```ruby
|
362
|
+
class FailingWorker
|
363
|
+
include Sidekiq::Worker
|
364
|
+
|
365
|
+
def perform(arg1, arg2)
|
366
|
+
end
|
367
|
+
|
368
|
+
# Your method must accept an array of arguments
|
369
|
+
# These will be the same as those passed to `perform`
|
370
|
+
def self.current_user(args)
|
371
|
+
arg1 = args[0]
|
372
|
+
arg2 = args[1]
|
373
|
+
|
374
|
+
user = User.find_by(name: arg1)
|
375
|
+
|
376
|
+
# Your method must return a user object
|
377
|
+
user
|
378
|
+
end
|
379
|
+
```
|
380
|
+
|
355
381
|
### Other Configuration options
|
356
382
|
|
357
383
|
For a complete list of configuration options see the [configuration.rb](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb) file
|
data/lib/raygun/sidekiq.rb
CHANGED
@@ -19,12 +19,38 @@ module Raygun
|
|
19
19
|
|
20
20
|
class SidekiqReporter
|
21
21
|
def self.call(exception, context_hash)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
user = affected_user(context_hash)
|
23
|
+
data = {
|
24
|
+
custom_data: {
|
25
|
+
sidekiq_context: context_hash
|
26
|
+
}
|
27
|
+
}
|
28
|
+
::Raygun.track_exception(
|
29
|
+
exception,
|
30
|
+
data,
|
31
|
+
user
|
26
32
|
)
|
27
33
|
end
|
34
|
+
|
35
|
+
# Extracts affected user information out of a Sidekiq worker class
|
36
|
+
def self.affected_user(context_hash)
|
37
|
+
job = context_hash[:job]
|
38
|
+
|
39
|
+
return if job.nil? || job['class'].nil? || !Module.const_defined?(job['class'])
|
40
|
+
|
41
|
+
worker_class = Module.const_get(job['class'])
|
42
|
+
affected_user_method = Raygun.configuration.affected_user_method
|
43
|
+
|
44
|
+
return if worker_class.nil? || !worker_class.respond_to?(affected_user_method)
|
45
|
+
|
46
|
+
worker_class.send(affected_user_method, job['args'])
|
47
|
+
rescue => e
|
48
|
+
return unless Raygun.configuration.failsafe_logger
|
49
|
+
|
50
|
+
failsafe_log("Problem in sidekiq affected user tracking: #{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}")
|
51
|
+
|
52
|
+
nil
|
53
|
+
end
|
28
54
|
end
|
29
55
|
end
|
30
56
|
|
@@ -38,4 +64,4 @@ else
|
|
38
64
|
Sidekiq.configure_server do |config|
|
39
65
|
config.error_handlers << Raygun::SidekiqReporter
|
40
66
|
end
|
41
|
-
end
|
67
|
+
end
|
data/lib/raygun/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raygun4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindscape
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|