airbrake_tools 1.1.2 → 1.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e92b3c3cba97f5cd88111d87a977ae81f41cbaf4
4
- data.tar.gz: aa24e7dee7bcb334d17c567c42a0d9de2664638e
3
+ metadata.gz: bdd1c1131520b79c11f048ba998705943ab95bc2
4
+ data.tar.gz: 29a5a90cc97973dbb2bed66ac01d66cd9a7a56f6
5
5
  SHA512:
6
- metadata.gz: e53ff74c73685daff36e1ab3e6df5381da368a1ccd754273aa1efc6fc41322e9eba4c0c10ff97f26a37bb4f5f7e81b56ccdcde596bfd5c5a400ec33769130682
7
- data.tar.gz: faf6a0cff78f8f5c6d199a7914b77b2bd615a4b42739528f52bafdc98af2d85d4ea0cd52cdc0333ff59be2dcc596252459ae50cdf46f51ebd755bf9a41fc99d4
6
+ metadata.gz: 15526a3a2541bbee47b30bb81235bc585eb80ccba968226c3c0d40cf44bf39e9cf51e6f023a81a0866490dc51a38b67f61431778e65d70b4a7bb634589d94973
7
+ data.tar.gz: 2f0a069e6fcf7e78a934d2d630c13af0b53530bbfd78a36b95cb6aaa76f93189776a3f33b0005aa0badf1cbe995a4271f1f78263a869403027ced6a7cb960906
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- airbrake_tools (1.1.2)
4
+ airbrake_tools (1.1.3)
5
5
  airbrake-api (>= 4.5.1)
6
6
 
7
7
  GEM
@@ -1,3 +1,3 @@
1
1
  module AirbrakeTools
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -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(:page => page) and page <= DEFAULT_SUMMARY_PAGES
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, :pages => pages, :raw => true).compact
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
- 60 * 60 # we got less notices then we wanted -> very few errors -> low frequency
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 * 60 * 60).round(2) # errors_per_hour
206
+ (errors_per_second * HOUR).round(2) # errors_per_hour
204
207
  end
205
208
 
206
209
  def hot_summary(error)
@@ -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.2
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-07-18 00:00:00.000000000 Z
11
+ date: 2014-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake-api