airbrake_tools 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/airbrake_tools/version.rb +1 -1
- data/lib/airbrake_tools.rb +8 -5
- data/spec/airbrake_tools_spec.rb +4 -0
- 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: bdd1c1131520b79c11f048ba998705943ab95bc2
|
4
|
+
data.tar.gz: 29a5a90cc97973dbb2bed66ac01d66cd9a7a56f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15526a3a2541bbee47b30bb81235bc585eb80ccba968226c3c0d40cf44bf39e9cf51e6f023a81a0866490dc51a38b67f61431778e65d70b4a7bb634589d94973
|
7
|
+
data.tar.gz: 2f0a069e6fcf7e78a934d2d630c13af0b53530bbfd78a36b95cb6aaa76f93189776a3f33b0005aa0badf1cbe995a4271f1f78263a869403027ced6a7cb960906
|
data/Gemfile.lock
CHANGED
data/lib/airbrake_tools.rb
CHANGED
@@ -6,6 +6,7 @@ require "launchy"
|
|
6
6
|
module AirbrakeTools
|
7
7
|
DEFAULT_HOT_PAGES = 1
|
8
8
|
DEFAULT_NEW_PAGES = 1
|
9
|
+
DEFAULT_LIST_PAGES = 10
|
9
10
|
DEFAULT_SUMMARY_PAGES = 10
|
10
11
|
DEFAULT_COMPARE_DEPTH_ADDITION = 3 # first line in project is 6 -> compare at 6 + x depth
|
11
12
|
DEFAULT_ENVIRONMENT = "production"
|
@@ -15,6 +16,7 @@ module AirbrakeTools
|
|
15
16
|
:bold => "\e[1m",
|
16
17
|
:clear => "\e[0m"
|
17
18
|
}
|
19
|
+
HOUR = 60*60
|
18
20
|
|
19
21
|
class << self
|
20
22
|
def cli(argv)
|
@@ -63,8 +65,9 @@ module AirbrakeTools
|
|
63
65
|
end
|
64
66
|
|
65
67
|
def list(options)
|
68
|
+
list_pages = options[:pages] ? options[:pages] : DEFAULT_LIST_PAGES
|
66
69
|
page = 1
|
67
|
-
while errors = AirbrakeAPI.errors(:
|
70
|
+
while errors = AirbrakeAPI.errors(page: page) and page <= list_pages
|
68
71
|
select_env(errors, options).each do |error|
|
69
72
|
puts "#{error.id} -- #{error.error_class} -- #{error.error_message} -- #{error.created_at}"
|
70
73
|
end
|
@@ -160,7 +163,7 @@ module AirbrakeTools
|
|
160
163
|
Parallel.map(errors, :in_threads => 10) do |error|
|
161
164
|
begin
|
162
165
|
pages = 1
|
163
|
-
notices = AirbrakeAPI.notices(error.id, :
|
166
|
+
notices = AirbrakeAPI.notices(error.id, pages: pages, raw: true).compact
|
164
167
|
print "."
|
165
168
|
[error, notices, frequency(notices, pages * AirbrakeAPI::Client::PER_PAGE)]
|
166
169
|
rescue Faraday::Error::ParsingError
|
@@ -194,13 +197,13 @@ module AirbrakeTools
|
|
194
197
|
# we only have a limited sample size, so we do not know how many errors occurred in total
|
195
198
|
def frequency(notices, expected_notices)
|
196
199
|
return 0 if notices.empty?
|
197
|
-
range = if notices.size < expected_notices
|
198
|
-
|
200
|
+
range = if notices.size < expected_notices && notices.last.created_at > (Time.now - HOUR)
|
201
|
+
HOUR # we got less notices then we wanted -> very few errors -> low frequency
|
199
202
|
else
|
200
203
|
Time.now - notices.map{ |n| n.created_at }.min
|
201
204
|
end
|
202
205
|
errors_per_second = notices.size / range.to_f
|
203
|
-
(errors_per_second *
|
206
|
+
(errors_per_second * HOUR).round(2) # errors_per_hour
|
204
207
|
end
|
205
208
|
|
206
209
|
def hot_summary(error)
|
data/spec/airbrake_tools_spec.rb
CHANGED
@@ -178,6 +178,10 @@ describe "airbrake-tools" do
|
|
178
178
|
it "calculates low if notices are smaller then expected notices" do
|
179
179
|
AirbrakeTools.send(:frequency, [stub(:created_at => Time.now)], 10).should == 1
|
180
180
|
end
|
181
|
+
|
182
|
+
it "calculates correct if notices are smaller then expected notices but old" do
|
183
|
+
AirbrakeTools.send(:frequency, [stub(:created_at => (Time.now - 2 * 60 * 60))], 10).should == 0.5
|
184
|
+
end
|
181
185
|
end
|
182
186
|
|
183
187
|
describe ".select_env" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrake_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Cheatham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake-api
|