airbrake_tools 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +10 -2
- data/Readme.md +1 -1
- data/lib/airbrake_tools.rb +26 -17
- data/lib/airbrake_tools/version.rb +1 -1
- data/spec/airbrake_tools_spec.rb +3 -3
- data/spec/fixtures.example.yml +1 -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: fc3d7af0e6a7b6fc87ca968b446c774e970acd57
|
4
|
+
data.tar.gz: 69733ce8c83cc4a147ec7c3c9655e4a9cb00a737
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2988f6f938cee2117380a1f52c8307440899e8e4f389aefd3227719b9a85b0f2c00af4408ab86041bdfe8763b85e47d59bf358904b62291ff11d7003b30eca4
|
7
|
+
data.tar.gz: 9e899108980cdbff2044dd0d30d686f38ed8a5583a03ee85b7d131b4f7da4ffd5f89920dbfafb66bae036bde61ea04999b16ab04dc3985ba36eb38cbee1b9c24
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
airbrake_tools (1.1.
|
4
|
+
airbrake_tools (1.1.4)
|
5
5
|
airbrake-api (>= 4.5.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -14,12 +14,18 @@ GEM
|
|
14
14
|
multi_xml
|
15
15
|
parallel
|
16
16
|
bump (0.3.8)
|
17
|
+
byebug (3.5.1)
|
18
|
+
columnize (~> 0.8)
|
19
|
+
debugger-linecache (~> 1.2)
|
20
|
+
slop (~> 3.6)
|
21
|
+
columnize (0.8.9)
|
22
|
+
debugger-linecache (1.2.0)
|
17
23
|
diff-lcs (1.1.3)
|
18
24
|
faraday (0.9.0)
|
19
25
|
multipart-post (>= 1.2, < 3)
|
20
26
|
faraday_middleware (0.9.1)
|
21
27
|
faraday (>= 0.7.4, < 0.10)
|
22
|
-
hashie (
|
28
|
+
hashie (3.3.1)
|
23
29
|
launchy (2.4.2)
|
24
30
|
addressable (~> 2.3)
|
25
31
|
multi_xml (0.5.5)
|
@@ -34,6 +40,7 @@ GEM
|
|
34
40
|
rspec-expectations (2.11.3)
|
35
41
|
diff-lcs (~> 1.1.3)
|
36
42
|
rspec-mocks (2.11.3)
|
43
|
+
slop (3.6.0)
|
37
44
|
|
38
45
|
PLATFORMS
|
39
46
|
ruby
|
@@ -41,6 +48,7 @@ PLATFORMS
|
|
41
48
|
DEPENDENCIES
|
42
49
|
airbrake_tools!
|
43
50
|
bump (= 0.3.8)
|
51
|
+
byebug
|
44
52
|
launchy
|
45
53
|
rake
|
46
54
|
rspec (~> 2)
|
data/Readme.md
CHANGED
@@ -39,7 +39,7 @@ Shows all errors divided by pages
|
|
39
39
|
- "fix all errors on page x"
|
40
40
|
|
41
41
|
```
|
42
|
-
airbrake-tools your-account your-auth-token list | grep 'is suspended'
|
42
|
+
airbrake-tools your-account your-auth-token list --project 12345 | grep 'is suspended'
|
43
43
|
Page 1 ----------
|
44
44
|
54054554 -- ActiveRecord::RecordInvalid -- ActiveRecord::RecordInvalid: Validation failed: Requester is suspended.
|
45
45
|
Page 2 ----------
|
data/lib/airbrake_tools.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require "airbrake_tools/version"
|
3
2
|
require "airbrake-api"
|
4
|
-
require "launchy"
|
5
3
|
|
6
4
|
module AirbrakeTools
|
7
5
|
DEFAULT_HOT_PAGES = 1
|
@@ -51,13 +49,16 @@ module AirbrakeTools
|
|
51
49
|
end
|
52
50
|
|
53
51
|
def hot(options = {})
|
54
|
-
errors =
|
55
|
-
|
52
|
+
errors = Array(options[:project_id] || projects.map(&:id)).flat_map do |project_id|
|
53
|
+
errors_with_notices({pages: DEFAULT_HOT_PAGES, project_id: project_id}.merge(options))
|
54
|
+
end
|
55
|
+
errors.sort_by{|_,_,f| f }.reverse[0...AirbrakeAPI::Client::PER_PAGE]
|
56
56
|
end
|
57
57
|
|
58
58
|
def new(options = {})
|
59
|
+
need_project_id!(options)
|
59
60
|
errors = errors_with_notices({:pages => DEFAULT_NEW_PAGES}.merge(options))
|
60
|
-
errors.sort_by{|e,
|
61
|
+
errors.sort_by{|e,_,_| e.created_at }.reverse
|
61
62
|
end
|
62
63
|
|
63
64
|
def errors_with_notices(options)
|
@@ -65,9 +66,10 @@ module AirbrakeTools
|
|
65
66
|
end
|
66
67
|
|
67
68
|
def list(options)
|
68
|
-
|
69
|
+
need_project_id!(options)
|
70
|
+
list_pages = (options[:pages] ? options[:pages] : DEFAULT_LIST_PAGES)
|
69
71
|
page = 1
|
70
|
-
while errors = AirbrakeAPI.errors(page: page
|
72
|
+
while page <= list_pages && errors = AirbrakeAPI.errors(page: page, project_id: options.fetch(:project_id))
|
71
73
|
select_env(errors, options).each do |error|
|
72
74
|
puts "#{error.id} -- #{error.error_class} -- #{error.error_message} -- #{error.created_at}"
|
73
75
|
end
|
@@ -92,20 +94,23 @@ module AirbrakeTools
|
|
92
94
|
end
|
93
95
|
|
94
96
|
def open(error_id, notice_id=nil)
|
97
|
+
require "launchy"
|
95
98
|
error = AirbrakeAPI.error(error_id)
|
96
99
|
raise URI::InvalidURIError if error.nil?
|
97
100
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
Launchy.open "https://#{AirbrakeAPI.account}.airbrake.io/projects/#{error.project_id}/groups/#{error_id}/notices/#{notice_id}"
|
102
|
-
end
|
101
|
+
url = "https://#{AirbrakeAPI.account}.airbrake.io/projects/#{error.project_id}/groups/#{error_id}"
|
102
|
+
url += "/notices/#{notice_id}" if notice_id
|
103
|
+
Launchy.open url
|
103
104
|
rescue URI::InvalidURIError
|
104
105
|
puts "Error id does not map to any error on Airbrake"
|
105
106
|
end
|
106
107
|
|
107
108
|
private
|
108
109
|
|
110
|
+
def need_project_id!(options)
|
111
|
+
raise "Need a project_id" unless options[:project_id]
|
112
|
+
end
|
113
|
+
|
109
114
|
def present_line(line)
|
110
115
|
color = :gray if $stdout.tty? && !custom_file?(line)
|
111
116
|
line = line.sub("[PROJECT_ROOT]/", "")
|
@@ -187,7 +192,7 @@ module AirbrakeTools
|
|
187
192
|
end
|
188
193
|
|
189
194
|
def print_errors(hot)
|
190
|
-
hot.each_with_index do |(error, notices, rate
|
195
|
+
hot.each_with_index do |(error, notices, rate), index|
|
191
196
|
spark = sparkline(notices, :slots => 60, :interval => 60)
|
192
197
|
puts "\n##{(index+1).to_s.ljust(2)} #{rate.round(2).to_s.rjust(6)}/hour total:#{error.notices_count.to_s.ljust(8)} #{color_text(spark.ljust(61), :green)}"
|
193
198
|
puts hot_summary(error)
|
@@ -234,7 +239,7 @@ module AirbrakeTools
|
|
234
239
|
opts.on("-c NUM", "--compare-depth NUM", Integer, "How deep to compare backtraces in summary (default: first line in project + #{DEFAULT_COMPARE_DEPTH_ADDITION})") {|s| options[:compare_depth] = s }
|
235
240
|
opts.on("-p NUM", "--pages NUM", Integer, "How maybe pages to iterate over (default: hot:#{DEFAULT_HOT_PAGES} new:#{DEFAULT_NEW_PAGES} summary:#{DEFAULT_SUMMARY_PAGES})") {|s| options[:pages] = s }
|
236
241
|
opts.on("-e ENV", "--environment ENV", String, "Only show errors from this environment (default: #{DEFAULT_ENVIRONMENT})") {|s| options[:env] = s }
|
237
|
-
opts.on("--project
|
242
|
+
opts.on("--project NAME_OR_ID", String, "Name of project to fetch errors for") {|p| options[:project_name] = p }
|
238
243
|
opts.on("-h", "--help", "Show this.") { puts opts; exit }
|
239
244
|
opts.on("-v", "--version", "Show Version"){ puts "airbrake-tools #{VERSION}"; exit }
|
240
245
|
end.parse!(argv)
|
@@ -257,10 +262,14 @@ module AirbrakeTools
|
|
257
262
|
`#{File.expand_path('../../spark.sh',__FILE__)} #{sparkline_data(notices, options).join(" ")}`.strip
|
258
263
|
end
|
259
264
|
|
260
|
-
def
|
265
|
+
def projects
|
261
266
|
@projects ||= AirbrakeAPI.projects
|
262
|
-
|
263
|
-
|
267
|
+
end
|
268
|
+
|
269
|
+
def project_id(project_name)
|
270
|
+
return project_name.to_i if project_name =~ /^\d+$/
|
271
|
+
project = projects.detect { |p| p.name == project_name }
|
272
|
+
raise "project with name #{project_name} not found try #{projects.map(&:name).join(", ")}" unless project
|
264
273
|
project.id
|
265
274
|
end
|
266
275
|
end
|
data/spec/airbrake_tools_spec.rb
CHANGED
@@ -45,14 +45,14 @@ describe "airbrake-tools" do
|
|
45
45
|
|
46
46
|
describe "hot" do
|
47
47
|
it "kinda works" do
|
48
|
-
output = airbrake_tools("#{config["subdomain"]} #{config["auth_token"]} hot")
|
48
|
+
output = airbrake_tools("#{config["subdomain"]} #{config["auth_token"]} hot --project #{config["project_id"]}")
|
49
49
|
output.should =~ /#\d+\s+\d+\.\d+\/hour\s+total:\d+/
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "list" do
|
54
54
|
it "kinda works" do
|
55
|
-
output = airbrake_tools("#{config["subdomain"]} #{config["auth_token"]} list")
|
55
|
+
output = airbrake_tools("#{config["subdomain"]} #{config["auth_token"]} list --project #{config["project_id"]}")
|
56
56
|
output.should include("Page 1 ")
|
57
57
|
output.should =~ /^\d+/
|
58
58
|
end
|
@@ -68,7 +68,7 @@ describe "airbrake-tools" do
|
|
68
68
|
|
69
69
|
describe "new" do
|
70
70
|
it "kinda works" do
|
71
|
-
output = airbrake_tools("#{config["subdomain"]} #{config["auth_token"]} new")
|
71
|
+
output = airbrake_tools("#{config["subdomain"]} #{config["auth_token"]} new --project #{config["project_id"]}")
|
72
72
|
output.should =~ /#\d+\s+\d+\.\d+\/hour\s+total:\d+/
|
73
73
|
end
|
74
74
|
end
|
data/spec/fixtures.example.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
1
|
subdomain: xxx
|
2
2
|
auth_token: yyy # NOT THE API KEY <-> got to airbrake, click on settings, copy auth_token
|
3
3
|
summary_error_id: zzz # some valid error ID from airbrake to test summary functionality
|
4
|
+
project_id: aaa # some valid project ID from airbrake to test new/list functionality
|
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.4
|
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-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake-api
|