airbrake_tools 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/airbrake_tools/version.rb +1 -1
- data/lib/airbrake_tools.rb +10 -5
- data/spec/airbrake_tools_spec.rb +8 -3
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/airbrake_tools.rb
CHANGED
@@ -91,9 +91,10 @@ module AirbrakeTools
|
|
91
91
|
def add_notices_to_pages(errors)
|
92
92
|
Parallel.map(errors, :in_threads => 10) do |error|
|
93
93
|
begin
|
94
|
-
|
94
|
+
pages = 1
|
95
|
+
notices = AirbrakeAPI.notices(error.id, :pages => pages, :raw => true).compact
|
95
96
|
print "."
|
96
|
-
[error, notices, frequency(notices)]
|
97
|
+
[error, notices, frequency(notices, pages * AirbrakeAPI::Client::PER_PAGE)]
|
97
98
|
rescue Faraday::Error::ParsingError
|
98
99
|
$stderr.puts "Ignoring #{hot_summary(error)}, got 500 from http://#{AirbrakeAPI.account}.airbrake.io/errors/#{error.id}"
|
99
100
|
end
|
@@ -119,10 +120,14 @@ module AirbrakeTools
|
|
119
120
|
end
|
120
121
|
|
121
122
|
# we only have a limited sample size, so we do not know how many errors occurred in total
|
122
|
-
def frequency(notices)
|
123
|
+
def frequency(notices, expected_notices)
|
123
124
|
return 0 if notices.empty?
|
124
|
-
range =
|
125
|
-
|
125
|
+
range = if notices.size < expected_notices
|
126
|
+
60 * 60 # we got less notices then we wanted -> very few errors -> low frequency
|
127
|
+
else
|
128
|
+
Time.now - notices.map{ |n| n.created_at }.min
|
129
|
+
end
|
130
|
+
errors_per_second = notices.size / range.to_f
|
126
131
|
(errors_per_second * 60 * 60).round(2) # errors_per_hour
|
127
132
|
end
|
128
133
|
|
data/spec/airbrake_tools_spec.rb
CHANGED
@@ -93,16 +93,21 @@ describe "airbrake-tools" do
|
|
93
93
|
|
94
94
|
describe ".frequency" do
|
95
95
|
it "calculates for 0" do
|
96
|
-
AirbrakeTools.send(:frequency, []).should == 0
|
96
|
+
AirbrakeTools.send(:frequency, [], 0).should == 0
|
97
|
+
AirbrakeTools.send(:frequency, [], 1).should == 0
|
97
98
|
end
|
98
99
|
|
99
100
|
it "calculates for 1" do
|
100
|
-
AirbrakeTools.send(:frequency, [stub(:created_at => Time.now - (60*60))]).should == 1
|
101
|
+
AirbrakeTools.send(:frequency, [stub(:created_at => Time.now - (60*60))], 1).should == 1
|
101
102
|
end
|
102
103
|
|
103
104
|
it "calculates for n" do
|
104
105
|
# 3 per minute => 180/hour
|
105
|
-
AirbrakeTools.send(:frequency, [stub(:created_at => Time.now-60), stub(:created_at => Time.now-40), stub(:created_at => Time.now-20)]).should == 180
|
106
|
+
AirbrakeTools.send(:frequency, [stub(:created_at => Time.now-60), stub(:created_at => Time.now-40), stub(:created_at => Time.now-20)], 3).should == 180
|
107
|
+
end
|
108
|
+
|
109
|
+
it "calculates low if notices are smaller then expected notices" do
|
110
|
+
AirbrakeTools.send(:frequency, [stub(:created_at => Time.now)], 10).should == 1
|
106
111
|
end
|
107
112
|
end
|
108
113
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrake_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: airbrake-api
|