rorvswild 1.5.12 → 1.5.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48093e6f93439e8216bd5b0c631b6b56386281d9792f728312d227634834ee11
4
- data.tar.gz: 9d7cc84527fc054d47e17ed8f8c736c119660f59d7f077a24b420588875e0685
3
+ metadata.gz: 262b40730d9fc77d334a2f3b4da10d4ddaea1cbd06b5c6c7da320d214ce18715
4
+ data.tar.gz: abe5d9f0bcda336c7ced3a1eee9071c3d9fdef32c9c49c45914fb483d093ed2f
5
5
  SHA512:
6
- metadata.gz: 55d90ef1666a3e5696cfbf998a13446d8dc2cddeccf05d56d5dcc6aa3855e5bd5443eb0dccd0b2d54e6af00b1e5babce359fabd2899a4a624a0fcb9f5ab1a5c4
7
- data.tar.gz: 909982650664ed49fed2103c7e031ae761ccea22eb5fd39bb82b85e2e3996fd7ec28b891b2151d41ebeadae6f2076ff3c14d895e0a552c006e444e6178d77754
6
+ metadata.gz: 2b809c27a4e650398c384ee828026381828d145393ea13f31d02cedc9b17be540dd0bec22845b293526d33658b33e5118faddaebf21866016c902f233e30a722
7
+ data.tar.gz: 9c75b3789da4f450ee58bd47b9bdbb536b6076a28af82366b2c18f4546e5e2d04cbe8df5c4db1362731b83719e1713a2525bc03b25cb5108eab56827056717a5
data/README.md CHANGED
@@ -136,6 +136,18 @@ RorVsWild.record_error(exception, {something: "important"})
136
136
  RorVsWild.catch_error(something: "important") { 1 / 0 }
137
137
  ```
138
138
 
139
+ It is also possible to pre-fill this context data at the begining of each request or job :
140
+
141
+ ```ruby
142
+ class ApplicationController < ActionController::Base
143
+ before_action :prefill_error_context
144
+
145
+ def prefill_error_context
146
+ RorVsWild.merge_error_context(something: "important")
147
+ end
148
+ end
149
+ ```
150
+
139
151
  #### Ignore requests, jobs, exceptions and plugins
140
152
 
141
153
  From the configuration file, you can tell RorVsWild to skip monitoring some requests, jobs, exceptions and plugins.
@@ -113,6 +113,18 @@ module RorVsWild
113
113
  current_data[:error]
114
114
  end
115
115
 
116
+ def merge_error_context(hash)
117
+ self.error_context = error_context ? error_context.merge(hash) : hash
118
+ end
119
+
120
+ def error_context
121
+ current_data[:error_context] if current_data
122
+ end
123
+
124
+ def error_context=(hash)
125
+ current_data[:error_context] = hash if current_data
126
+ end
127
+
116
128
  def current_data
117
129
  Thread.current[:rorvswild_data]
118
130
  end
@@ -162,15 +174,16 @@ module RorVsWild
162
174
  client.post_async("/errors".freeze, error: hash)
163
175
  end
164
176
 
165
- def exception_to_hash(exception, extra_details = nil)
177
+ def exception_to_hash(exception, context = nil)
166
178
  file, line = locator.find_most_relevant_file_and_line_from_exception(exception)
179
+ context = context ? error_context.merge(context) : error_context if error_context
167
180
  {
168
181
  line: line.to_i,
169
182
  file: locator.relative_path(file),
170
183
  message: exception.message,
171
184
  backtrace: exception.backtrace || ["No backtrace"],
172
185
  exception: exception.class.to_s,
173
- extra_details: extra_details,
186
+ extra_details: context,
174
187
  environment: {
175
188
  os: os_description,
176
189
  user: Etc.getlogin,
@@ -1,3 +1,3 @@
1
1
  module RorVsWild
2
- VERSION = "1.5.12".freeze
2
+ VERSION = "1.5.13".freeze
3
3
  end
data/lib/rorvswild.rb CHANGED
@@ -39,6 +39,10 @@ module RorVsWild
39
39
  agent.record_error(exception, extra_details) if agent
40
40
  end
41
41
 
42
+ def self.merge_error_context(hash)
43
+ agent.merge_error_context(hash) if agent
44
+ end
45
+
42
46
  def self.initialize_logger(destination = nil)
43
47
  if destination.respond_to?(:info) && destination.respond_to?(:warn) && destination.respond_to?(:error)
44
48
  destination
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rorvswild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.12
4
+ version: 1.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-05-22 00:00:00.000000000 Z
12
+ date: 2021-12-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Performances and errors insights for rails developers.
15
15
  email: